mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
[kernel] Simplify event and wait_queue
Previously event tried to read its value in event::wake_observer, which required jumping through some hoops in how wait_queue was designed, so that a value wouldn't be wasted if the wait_queue was empty. Now, read the event value in event::wait after returning from the thread::block call instead, which simplifies the whole process and lets us simplify the wait_queue API as well.
This commit is contained in:
@@ -15,30 +15,14 @@ public:
|
||||
/// Wake all threads when destructing
|
||||
~wait_queue();
|
||||
|
||||
/// Add the given thread to the queue. Locks the
|
||||
/// queue lock.
|
||||
/// Add the given thread to the queue.
|
||||
void add_thread(obj::thread *t);
|
||||
|
||||
/// Block the current thread on the queue.
|
||||
void wait();
|
||||
|
||||
/// Pops the next waiting thread off the queue.
|
||||
/// Locks the queue lock.
|
||||
inline obj::thread * pop_next() {
|
||||
util::scoped_lock lock {m_lock};
|
||||
return pop_next_unlocked();
|
||||
}
|
||||
|
||||
/// Get the next waiting thread. Does not lock the
|
||||
/// queue lock.
|
||||
obj::thread * get_next_unlocked();
|
||||
|
||||
/// Pop the next thread off the queue. Does not
|
||||
/// lock the queue lock.
|
||||
obj::thread * pop_next_unlocked();
|
||||
|
||||
/// Get the spinlock to lock this queue
|
||||
util::spinlock & get_lock() { return m_lock; }
|
||||
obj::thread * pop_next();
|
||||
|
||||
/// Wake and clear out all threads.
|
||||
/// \arg value The value passed to thread::wake
|
||||
|
||||
Reference in New Issue
Block a user