diff --git a/src/state.hpp b/src/state.hpp index 669eac3..3a26a10 100644 --- a/src/state.hpp +++ b/src/state.hpp @@ -22,8 +22,7 @@ namespace cw::state std::queue queue; bool pause_work, stop_work; - std::mutex mutex_queue; - std::mutex mutex_allocator; + std::mutex mutex; State(void) {}; }; diff --git a/src/worker.cpp b/src/worker.cpp index 14df57e..5ba505b 100644 --- a/src/worker.cpp +++ b/src/worker.cpp @@ -35,27 +35,23 @@ namespace cw::worker void do_iteration(State &state) { - state.mutex_queue.lock(); + // state.mutex.lock(); if (state.queue.empty()) { // Unlock since there isn't any work to be done. - state.mutex_queue.unlock(); + // state.mutex.unlock(); return; } u64 index = state.queue.front(); state.queue.pop(); - state.mutex_queue.unlock(); u64 left_child, right_child; - state.mutex_allocator.lock(); std::tie(left_child, right_child) = generate_children(state.allocator, index); - state.mutex_allocator.unlock(); - state.mutex_queue.lock(); state.queue.push(left_child); state.queue.push(right_child); - state.mutex_queue.unlock(); + // state.mutex.unlock(); } void worker(State &state) diff --git a/src/worker.hpp b/src/worker.hpp index 5d437e6..fc38651 100644 --- a/src/worker.hpp +++ b/src/worker.hpp @@ -18,7 +18,7 @@ namespace cw::worker using cw::node::NodeAllocator; using cw::state::State; constexpr auto THREAD_PAUSE_DELAY = std::chrono::milliseconds(1000); - constexpr auto THREAD_GENERAL_DELAY = std::chrono::milliseconds(1); + constexpr auto THREAD_GENERAL_DELAY = std::chrono::nanoseconds(100); // Given `index`, return the indices of its children in the tree. If not // present already, generate them using the allocator.