This strategy is a simple sharing strategy. More...
#include <SimpleSharing.hpp>
Public Member Functions | |
SimpleSharing (const std::shared_ptr< ClauseDatabase > &clauseDB, unsigned int sizeLimitAtImport, unsigned long literalsPerRoundPerProducer, const std::vector< std::shared_ptr< SharingEntity > > &producers={}, const std::vector< std::shared_ptr< SharingEntity > > &consumers={}) | |
Constructor for SimpleSharing. | |
~SimpleSharing () | |
Destructor for SimpleSharing. | |
bool | importClause (const ClauseExchangePtr &clause) override |
Imports a single clause. Clauses are tested against sizeLimit before. | |
void | importClauses (const std::vector< ClauseExchangePtr > &v_clauses) override |
Imports multiple clauses. | |
bool | doSharing () override |
Performs the sharing operation. | |
Public Member Functions inherited from SharingStrategy | |
SharingStrategy (const std::vector< std::shared_ptr< SharingEntity > > &producers, const std::vector< std::shared_ptr< SharingEntity > > &consumers, const std::shared_ptr< ClauseDatabase > &clauseDB) | |
Constructor for SharingStrategy. Be sure to call connectConstructorProducers after construction, this is due to the base class shared_from_this. | |
virtual | ~SharingStrategy () |
Virtual destructor. | |
virtual std::chrono::microseconds | getSleepingTime () |
Determines the sleeping time for the sharer. | |
virtual void | printStats () |
Prints the statistics of the strategy. | |
void | connectConstructorProducers () |
Add this to the producers' clients list. | |
virtual void | addProducer (std::shared_ptr< SharingEntity > producer) |
Adds a producer to this strategy. | |
virtual void | connectProducer (std::shared_ptr< SharingEntity > producer) |
Connect a producer to this strategy. Add (this) to clients of (producer) | |
virtual void | removeProducer (std::shared_ptr< SharingEntity > producer) |
Removes a producer from this strategy. | |
Public Member Functions inherited from SharingEntity | |
SharingEntity () | |
Construct a new SharingEntity object. | |
SharingEntity (const std::vector< std::shared_ptr< SharingEntity > > &clients) | |
Construct a new SharingEntity object. | |
virtual | ~SharingEntity () |
Destroy the SharingEntity object. | |
int | getSharingId () const |
Get the sharing ID of this entity. | |
void | setSharingId (int _id) |
Set the sharing ID of this entity. | |
virtual void | addClient (std::shared_ptr< SharingEntity > client) |
Add a client to this entity. | |
virtual void | removeClient (std::shared_ptr< SharingEntity > client) |
Remove a specific client from this entity. | |
size_t | getClientCount () const |
Get the current number of clients. | |
void | clearClients () |
Remove all clients. | |
Protected Attributes | |
int | literalPerRound |
Number of shared literals per round. | |
std::vector< ClauseExchangePtr > | selection |
Used to manipulate clauses (as a member to reduce number of allocations). | |
unsigned int | sizeLimit |
Maximum clause size. | |
Protected Attributes inherited from SharingStrategy | |
std::shared_ptr< ClauseDatabase > | m_clauseDB |
Clause database where exported clauses are stored. | |
SharingStatistics | stats |
Sharing statistics. | |
std::vector< std::weak_ptr< SharingEntity > > | m_producers |
The set holding the references to the producers. | |
std::shared_mutex | m_producersMutex |
Shared mutex for producers list (to become RCU ?) | |
Protected Attributes inherited from SharingEntity | |
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. | |
Additional Inherited Members | |
Protected Member Functions inherited from SharingStrategy | |
bool | exportClauseToClient (const ClauseExchangePtr &clause, std::shared_ptr< SharingEntity > client) override |
A SharingStrategy doesn't send a clause to the source client (->from must store the sharingId of its producer) | |
Protected Member Functions inherited from SharingEntity | |
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. | |
This strategy is a simple sharing strategy.
SimpleSharing::SimpleSharing | ( | const std::shared_ptr< ClauseDatabase > & | clauseDB, |
unsigned int | sizeLimitAtImport, | ||
unsigned long | literalsPerRoundPerProducer, | ||
const std::vector< std::shared_ptr< SharingEntity > > & | producers = {}, | ||
const std::vector< std::shared_ptr< SharingEntity > > & | consumers = {} ) |
Constructor for SimpleSharing.
clauseDB | Shared pointer to the clause database. |
producers | Vector of shared pointers to producer entities. |
consumers | Vector of shared pointers to consumer entities. |
sizeLimitAtImport | The maximum size of allowed clauses at import. |
literalsPerRoundPerProducer | The number of literals each producer should export at each round. |
|
overridevirtual |
Performs the sharing operation.
Implements SharingStrategy.
|
overridevirtual |
Imports a single clause. Clauses are tested against sizeLimit before.
clause | Pointer to the clause to be imported. |
Implements SharingEntity.
|
inlineoverridevirtual |
Imports multiple clauses.
v_clauses | Vector of clause pointers to be imported. |
Implements SharingEntity.