SharingStrategy class, inheriting from SharingEntity.
More...
#include <SharingStrategy.hpp>
|
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)
|
|
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::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 ?)
|
|
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.
|
|
SharingStrategy class, inheriting from SharingEntity.
SharingStrategy serves as a central manager that receives clauses from producers and distributes them to consumers. It orchestrates the exchange of clauses between different entities in a solver.
- Todo
Private constructors (+ move and copy constructors), wrappers for constructors that calls connectProducers and returns a smart pointer
Test userspace RCU for m_producers
◆ SharingStrategy()
SharingStrategy::SharingStrategy |
( |
const std::vector< std::shared_ptr< SharingEntity > > & | producers, |
|
|
const std::vector< std::shared_ptr< SharingEntity > > & | consumers, |
|
|
const std::shared_ptr< ClauseDatabase > & | clauseDB ) |
|
inline |
Constructor for SharingStrategy. Be sure to call connectConstructorProducers after construction, this is due to the base class shared_from_this.
- Parameters
-
producers | A vector of shared pointers to SharingEntity objects that produce clauses. |
consumers | A vector of shared pointers to SharingEntity objects that consume clauses. |
clauseDB | A shared pointer to the ClauseDatabase where exported clauses are stored. |
This constructor initializes the SharingStrategy with the given producers, consumers, and clause database. It stores weak pointers to the producers and consumers internally since it doesn't own the object but just communicate with it if possible.
- Warning
- Be sure to call connectConstructorProducers after construction, this is due to the base class shared_from_this
◆ addProducer()
virtual void SharingStrategy::addProducer |
( |
std::shared_ptr< SharingEntity > | producer | ) |
|
|
inlinevirtual |
Adds a producer to this strategy.
- Parameters
-
Reimplemented in HordeSatSharing.
◆ connectConstructorProducers()
void SharingStrategy::connectConstructorProducers |
( |
| ) |
|
|
inline |
Add this to the producers' clients list.
- Warning
- Be Careful! connect only constructor lists, (otherwise this strategy can be added twice)
◆ connectProducer()
virtual void SharingStrategy::connectProducer |
( |
std::shared_ptr< SharingEntity > | producer | ) |
|
|
inlinevirtual |
Connect a producer to this strategy. Add (this) to clients of (producer)
- Parameters
-
- Warning
- A producer should be connect only if it was added beforehand (necessary initialization done)
◆ doSharing()
virtual bool SharingStrategy::doSharing |
( |
| ) |
|
|
pure virtual |
◆ exportClauseToClient()
bool SharingStrategy::exportClauseToClient |
( |
const ClauseExchangePtr & | clause, |
|
|
std::shared_ptr< SharingEntity > | client ) |
|
inlineoverrideprotectedvirtual |
A SharingStrategy doesn't send a clause to the source client (->from must store the sharingId of its producer)
Reimplemented from SharingEntity.
◆ getSleepingTime()
virtual std::chrono::microseconds SharingStrategy::getSleepingTime |
( |
| ) |
|
|
inlinevirtual |
◆ printStats()
virtual void SharingStrategy::printStats |
( |
| ) |
|
|
inlinevirtual |
◆ removeProducer()
virtual void SharingStrategy::removeProducer |
( |
std::shared_ptr< SharingEntity > | producer | ) |
|
|
inlinevirtual |
Removes a producer from this strategy.
- Parameters
-
Reimplemented in HordeSatSharing.
The documentation for this class was generated from the following file: