IdleMonitor: new class to replace GlobalEvents::IDLE
Use MaskMonitor to eliminate duplicate code.
This commit is contained in:
15
src/Idle.cxx
15
src/Idle.cxx
@@ -27,25 +27,12 @@
|
||||
#include "Main.hxx"
|
||||
#include "Instance.hxx"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
static std::atomic_uint idle_flags;
|
||||
|
||||
void
|
||||
idle_add(unsigned flags)
|
||||
{
|
||||
assert(flags != 0);
|
||||
|
||||
unsigned old_flags = idle_flags.fetch_or(flags);
|
||||
|
||||
if ((old_flags & flags) != flags)
|
||||
instance->global_events.Emit(GlobalEvents::IDLE);
|
||||
}
|
||||
|
||||
unsigned
|
||||
idle_get(void)
|
||||
{
|
||||
return idle_flags.exchange(0);
|
||||
instance->EmitIdle(flags);
|
||||
}
|
||||
|
Reference in New Issue
Block a user