3#include "containers/ClauseExchange.hpp"
5#include "utils/Parameters.hpp"
7#include <boost/lockfree/policies.hpp>
8#include <boost/lockfree/queue.hpp>
28 boost::lockfree::queue<ClauseExchange*, boost::lockfree::fixed_sized<false>> queue;
29 std::atomic<size_t> m_size;
85 if (queue.push(raw)) {
86 m_size.fetch_add(1, std::memory_order_release);
100 size_t addClauses(
const std::vector<ClauseExchangePtr>& clauses)
102 size_t old_size = m_size.load(std::memory_order_relaxed);
104 for (
const auto& clause : clauses) {
108 return m_size.load(std::memory_order_acquire) - old_size;
123 if (queue.bounded_push(raw)) {
124 m_size.fetch_add(1, std::memory_order_release);
143 size_t old_size = m_size.load(std::memory_order_relaxed);
144 for (
const auto& clause : clauses) {
150 return m_size.load(std::memory_order_acquire) - old_size;
162 if (queue.pop(raw)) {
164 m_size.fetch_sub(1, std::memory_order_release);
177 while (queue.pop(raw)) {
179 m_size.fetch_sub(1, std::memory_order_release);
187 size_t size()
const {
return m_size.load(std::memory_order_acquire); }
195 while (queue.pop(raw)) {
198 m_size.store(0, std::memory_order_release);
205 bool empty()
const {
return m_size.load(std::memory_order_acquire) == 0; }
Defines logging functions and macros for the SAT solver.
#define LOGDEBUG3(...)
Log a debug message with verbosity level 4 and magenta color.
Definition Logger.hpp:229
Wrapper for boost::lockfree::queue to manage ClauseExchange objects.
Definition ClauseBuffer.hpp:26
ClauseBuffer()=delete
Default Constructor deleted to enforce parameterized constructor.
bool empty() const
Checks if the buffer is empty.
Definition ClauseBuffer.hpp:205
void getClauses(std::vector< ClauseExchangePtr > &clauses)
Retrieves all available clauses from the buffer.
Definition ClauseBuffer.hpp:174
ClauseBuffer(ClauseBuffer &&)=default
Move constructor.
~ClauseBuffer()
Destructor.
Definition ClauseBuffer.hpp:75
bool addClause(ClauseExchangePtr clause)
Adds a single clause to the buffer.
Definition ClauseBuffer.hpp:82
size_t size() const
Returns the current number of clauses in the buffer.
Definition ClauseBuffer.hpp:187
ClauseBuffer(size_t size)
Constructs a ClauseBuffer with the specified size.
Definition ClauseBuffer.hpp:41
bool tryAddClauseBounded(ClauseExchangePtr clause)
Attempts to add a single clause to the buffer using bounded push.
Definition ClauseBuffer.hpp:120
void clear()
Clears all clauses from the buffer.
Definition ClauseBuffer.hpp:192
ClauseBuffer(const ClauseBuffer &)=delete
Copy constructor (deleted).
size_t tryAddClausesBounded(const std::vector< ClauseExchangePtr > &clauses)
Attempts to add multiple clauses to the buffer using bounded push.
Definition ClauseBuffer.hpp:141
size_t addClauses(const std::vector< ClauseExchangePtr > &clauses)
Adds multiple clauses to the buffer.
Definition ClauseBuffer.hpp:100
bool getClause(ClauseExchangePtr &clause)
Retrieves a single clause from the buffer.
Definition ClauseBuffer.hpp:158
ClauseBuffer & operator=(const ClauseBuffer &)=delete
Assignment operator (deleted).
ClauseBuffer(const ClauseBuffer &&)=delete
Move constructor (deleted).
ClauseBuffer & operator=(ClauseBuffer &&)=default
Move assignment operator.
Represents an exchangeable clause with flexible array member.
Definition ClauseExchange.hpp:42
ClauseExchange * toRawPtr()
Convert to a raw pointer and increment the reference count.
Definition ClauseExchange.hpp:151
static ClauseExchangePtr fromRawPtr(ClauseExchange *ptr)
Create an intrusive_ptr from a raw pointer.
Definition ClauseExchange.hpp:162