A base class representing entities that can exchange clauses between themselves.
More...
#include <SharingEntity.hpp>
|
virtual bool | exportClauseToClient (const ClauseExchangePtr &clause, std::shared_ptr< SharingEntity > client) |
| Export a clause to a specific client.
|
|
bool | exportClause (const ClauseExchangePtr &clause) |
| Export a clause to all registered clients.
|
|
void | exportClauses (const std::vector< ClauseExchangePtr > &clauses) |
| Export multiple clauses to all registered clients.
|
|
|
std::vector< std::weak_ptr< SharingEntity > > | m_clients |
| List of weak pointers to client SharingEntities.
|
|
std::shared_mutex | m_clientsMutex |
| Mutex to protect access to m_clients.
|
|
A base class representing entities that can exchange clauses between themselves.
- Warning
- This class assumes all SharingEntity objects are managed by std::shared_ptr. Improper use of raw pointers or other smart pointer types may lead to undefined behavior.
- Todo
Test userspace RCU for m_clients list
shared_from_this is needed here ? Or only when we deal with producers in a SharingStrategy ?
◆ SharingEntity() [1/2]
SharingEntity::SharingEntity |
( |
| ) |
|
|
inline |
Construct a new SharingEntity object.
Automatically assigns a unique sharing ID to the entity.
- Warning
- This constructor should only be called through std::make_shared or a similar mechanism that ensures the object is owned by a shared_ptr.
◆ SharingEntity() [2/2]
SharingEntity::SharingEntity |
( |
const std::vector< std::shared_ptr< SharingEntity > > & | clients | ) |
|
|
inline |
Construct a new SharingEntity object.
Automatically assigns a unique sharing ID to the entity.
- Warning
- This constructor should only be called through std::make_shared or a similar mechanism that ensures the object is owned by a shared_ptr.
◆ addClient()
virtual void SharingEntity::addClient |
( |
std::shared_ptr< SharingEntity > | client | ) |
|
|
inlinevirtual |
Add a client to this entity.
- Parameters
-
◆ exportClause()
bool SharingEntity::exportClause |
( |
const ClauseExchangePtr & | clause | ) |
|
|
inlineprotected |
Export a clause to all registered clients.
- Parameters
-
clause | The clause to export. |
- Returns
- true if the clause was exported to any client, false otherwise.
- Note
- This method uses the exportClauseToClient primitive for each clause and client combination. Subclasses can customize the behavior of clause export by overriding the exportClauseToClient method.
◆ exportClauses()
void SharingEntity::exportClauses |
( |
const std::vector< ClauseExchangePtr > & | clauses | ) |
|
|
inlineprotected |
Export multiple clauses to all registered clients.
- Parameters
-
clauses | A vector of clauses to export. |
- Note
- This method uses the exportClauseToClient primitive for each clause and client combination. Subclasses can customize the behavior of clause export by overriding the exportClauseToClient method.
◆ exportClauseToClient()
virtual bool SharingEntity::exportClauseToClient |
( |
const ClauseExchangePtr & | clause, |
|
|
std::shared_ptr< SharingEntity > | client ) |
|
inlineprotectedvirtual |
Export a clause to a specific client.
- Parameters
-
clause | The clause to export. |
client | The client to export the clause to. |
- Returns
- true if the clause was exported to the client, false otherwise.
- Note
- This is a primitive method intended to be redefined by subclasses. It is used by the exportClauses method to handle the export of individual clauses.
- Warning
- This method is not thread-safe and cannot be called concurrently.
Reimplemented in GlobalSharingStrategy, MallobSharing, and SharingStrategy.
◆ getClientCount()
size_t SharingEntity::getClientCount |
( |
| ) |
const |
|
inline |
Get the current number of clients.
- Returns
- The number of clients currently registered with this entity.
This method is thread-safe and can be called concurrently. Note: This count includes expired weak pointers that haven't been cleaned up yet.
◆ getSharingId()
int SharingEntity::getSharingId |
( |
| ) |
const |
|
inline |
Get the sharing ID of this entity.
- Returns
- The sharing ID.
◆ importClause()
virtual bool SharingEntity::importClause |
( |
const ClauseExchangePtr & | clause | ) |
|
|
pure virtual |
Import a single clause to this sharing entity.
- Parameters
-
- Returns
- true if clause was imported, false otherwise.
- Warning
- This method may be called concurrently from multiple threads. Derived classes should ensure thread-safety in their implementation.
Implemented in Cadical, GlobalSharingStrategy, GlucoseSyrup, HordeSatSharing, Kissat, KissatINCSolver, KissatMABSolver, Lingeling, MallobSharing, MapleCOMSPSSolver, MiniSat, and SimpleSharing.
◆ importClauses()
virtual void SharingEntity::importClauses |
( |
const std::vector< ClauseExchangePtr > & | v_clauses | ) |
|
|
pure virtual |
Import multiple clauses to this sharing entity.
- Parameters
-
v_clauses | The vector with the clauses to add. |
- Warning
- This method may be called concurrently from multiple threads. Derived classes should ensure thread-safety in their implementation.
Implemented in Cadical, GlobalSharingStrategy, GlucoseSyrup, HordeSatSharing, Kissat, KissatINCSolver, KissatMABSolver, Lingeling, MapleCOMSPSSolver, MiniSat, and SimpleSharing.
◆ removeClient()
virtual void SharingEntity::removeClient |
( |
std::shared_ptr< SharingEntity > | client | ) |
|
|
inlinevirtual |
Remove a specific client from this entity.
- Parameters
-
This method is thread-safe and can be called concurrently.
◆ setSharingId()
void SharingEntity::setSharingId |
( |
int | _id | ) |
|
|
inline |
Set the sharing ID of this entity.
- Parameters
-
The documentation for this class was generated from the following file: