3#include "SharingEntity.hpp"
4#include "containers/ClauseDatabase.hpp"
5#include "sharing/SharingStatistics.hpp"
43 const std::vector<std::shared_ptr<SharingEntity>>& consumers,
44 const std::shared_ptr<ClauseDatabase>& clauseDB)
49 LOGDEBUG1(
"Be sure to call connectConstructorProducers after construction, this is due to the base class "
68 virtual std::chrono::microseconds
getSleepingTime() {
return std::chrono::microseconds(__globalParameters__.sharingSleep); };
75 LOGSTAT(
"Strategy Basic Stats: receivedCls %d, sharedCls %d, filteredAtImport: %d",
89 if (
auto producer = weakProducer.lock())
90 producer->addClient(shared_from_this());
98 virtual void addProducer(std::shared_ptr<SharingEntity> producer)
102 LOGDEBUG2(
"[SharingStrategy] Added new producer");
112 producer->addClient(shared_from_this());
113 LOGDEBUG2(
"[SharingStrategy] Producer %u is connected!", producer->getSharingId());
123 producer->removeClient(shared_from_this());
127 [&producer](
const std::weak_ptr<SharingEntity>& wp) { return wp.lock() == producer; }),
129 LOGDEBUG2(
"[SharingStrategy] Removed producer");
138 if (clause->from != client->getSharingId())
139 return client->importClause(clause);
Defines logging functions and macros for the SAT solver.
#define LOGDEBUG2(...)
Log a debug message with verbosity level 2 and magenta color.
Definition Logger.hpp:221
#define LOGSTAT(...)
Log a statistics message.
Definition Logger.hpp:145
#define LOGDEBUG1(...)
Log a debug message with verbosity level 1 and blue color.
Definition Logger.hpp:213
A base class representing entities that can exchange clauses between themselves.
Definition SharingEntity.hpp:29
SharingStrategy class, inheriting from SharingEntity.
Definition SharingStrategy.hpp:26
virtual bool doSharing()=0
Executes the sharing process from producers to consumers.
virtual void removeProducer(std::shared_ptr< SharingEntity > producer)
Removes a producer from this strategy.
Definition SharingStrategy.hpp:120
virtual ~SharingStrategy()
Virtual destructor.
Definition SharingStrategy.hpp:56
virtual void addProducer(std::shared_ptr< SharingEntity > producer)
Adds a producer to this strategy.
Definition SharingStrategy.hpp:98
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 ...
Definition SharingStrategy.hpp:136
virtual void printStats()
Prints the statistics of the strategy.
Definition SharingStrategy.hpp:73
std::vector< std::weak_ptr< SharingEntity > > m_producers
The set holding the references to the producers.
Definition SharingStrategy.hpp:155
SharingStatistics stats
Sharing statistics.
Definition SharingStrategy.hpp:150
void connectConstructorProducers()
Add this to the producers' clients list.
Definition SharingStrategy.hpp:85
virtual void connectProducer(std::shared_ptr< SharingEntity > producer)
Connect a producer to this strategy. Add (this) to clients of (producer)
Definition SharingStrategy.hpp:110
virtual std::chrono::microseconds getSleepingTime()
Determines the sleeping time for the sharer.
Definition SharingStrategy.hpp:68
std::shared_ptr< ClauseDatabase > m_clauseDB
Clause database where exported clauses are stored.
Definition SharingStrategy.hpp:147
std::shared_mutex m_producersMutex
Shared mutex for producers list (to become RCU ?)
Definition SharingStrategy.hpp:158
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,...
Definition SharingStrategy.hpp:42
Local Sharing statistics.Sharing statistics.
Definition SharingStatistics.hpp:10
unsigned long sharedClauses
Number of shared clauses that have been shared.
Definition SharingStatistics.hpp:12
std::atomic< unsigned long > receivedClauses
Number of shared clauses produced.
Definition SharingStatistics.hpp:15
std::atomic< unsigned long > filteredAtImport
Number of clause filtered at import.
Definition SharingStatistics.hpp:18