Add mutexes to state for the queue and the allocator
Our threads need to negotiate access and mutation to the two resources - we don't want them treading on each others toes when generating new child nodes /or/ when trying to remove/add work to the queue. The former situation is particularly worrisome due to how weak the indexing system is with the allocator.
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
#ifndef STATE_HPP
|
#ifndef STATE_HPP
|
||||||
#define STATE_HPP
|
#define STATE_HPP
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
#include "base.hpp"
|
#include "base.hpp"
|
||||||
@@ -20,6 +21,9 @@ namespace cw::state
|
|||||||
cw::node::NodeAllocator allocator;
|
cw::node::NodeAllocator allocator;
|
||||||
std::queue<u64> queue;
|
std::queue<u64> queue;
|
||||||
|
|
||||||
|
std::mutex mutex_queue;
|
||||||
|
std::mutex mutex_allocator;
|
||||||
|
|
||||||
State(void);
|
State(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user