mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
[util] Add move-assignment operators to node_map, deque
Also add them to wait_queue as a wrapper to calling deque's move-assignmen operator.
This commit is contained in:
@@ -1,8 +1,20 @@
|
||||
#include <utility>
|
||||
#include "objects/thread.h"
|
||||
#include "wait_queue.h"
|
||||
|
||||
wait_queue::wait_queue(wait_queue &&other) :
|
||||
m_threads {std::move(other.m_threads)} {}
|
||||
|
||||
wait_queue::~wait_queue() { clear(); }
|
||||
|
||||
wait_queue &
|
||||
wait_queue::operator=(wait_queue &&other)
|
||||
{
|
||||
clear();
|
||||
m_threads = std::move(other.m_threads);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void
|
||||
wait_queue::add_thread(obj::thread *t)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,11 @@ namespace obj {
|
||||
class wait_queue
|
||||
{
|
||||
public:
|
||||
wait_queue() = default;
|
||||
wait_queue(wait_queue &&other);
|
||||
|
||||
wait_queue & operator=(wait_queue &&other);
|
||||
|
||||
/// Wake all threads when destructing
|
||||
~wait_queue();
|
||||
|
||||
@@ -28,6 +33,9 @@ public:
|
||||
/// \arg value The value passed to thread::wake
|
||||
void clear(uint64_t value = 0);
|
||||
|
||||
/// Check if the queue is empty
|
||||
bool empty() const { return m_threads.empty(); }
|
||||
|
||||
private:
|
||||
/// Get rid of any exited threads that are next
|
||||
/// in the queue. Caller must hold the queue lock.
|
||||
|
||||
Reference in New Issue
Block a user