34#ifndef _EXECUTOR_NOTIFIABLE_HXX_
35#define _EXECUTOR_NOTIFIABLE_HXX_
49#if OPENMRN_FEATURE_RTOS_FROM_ISR
50 virtual void notify_from_isr()
52 DIE(
"Unexpected call to notify_from_isr.");
74#if OPENMRN_FEATURE_RTOS_FROM_ISR
80 sem_.post_from_isr(&woken);
319#define AutoNotify(l) int error_omitted_autonotify_holder_variable[-1]
329 :
body_(std::move(body))
BarrierNotifiable * NewBarrierNotifiable(Notifiable *done)
Allocates a new barrier notifiable on the heap.
See OSMutexLock in os/OS.hxx.
Lightweight locking class for protecting small critical sections.
This class sends a notification in its destructor.
Notifiable * Transfer()
Transfers the ownership of the notification; it will NOT be called in the destructor.
Notifiable * n_
Stored notifiable to notify upon destruction.
~AutoNotify()
Destructor. Notifies the stored notifiable.
AutoNotify(Notifiable *n)
Constructor.
A BarrierNotifiable allows to create a number of child Notifiable and wait for all of them to finish.
BarrierNotifiable()
Constructs a barrier notifiable that is done.
void notify() override
Implementation of the barrier semantics.
unsigned count_
How many outstanding notifications we are still waiting for.
Notifiable * done_
Notifiable to call when the barrier reaches zero.
BarrierNotifiable * reset(Notifiable *done)
Resets the barrier. Returns &*this. Asserts that is_done().
BarrierNotifiable(Notifiable *done)
Constructs a barrier notifiable that is live.
void maybe_done()
When there are no more child tasks to add, call maybe_done().
BarrierNotifiable * new_child()
Call this for each child task.
bool abort_if_almost_done()
Checks if there is exactly one outstanding notification left in the barrier.
A Notifiable that will crash whenever called.
void notify() override
Crashes.
static Notifiable * DefaultInstance()
Base class of everything with a virtual destructor.
A Notifiable that doesn't do anything when notified.
void notify() override
Drops notification to the floor.
static Notifiable * DefaultInstance()
An object that can schedule itself on an executor to run.
virtual void notify()=0
Generic callback.
This class provides a counting semaphore API.
void post()
Post (increment) a semaphore.
void wait()
Wait on (decrement) a semaphore.
A class for reliably detecting whether a Notification has happened yet or not.
void notify() override
Implementation of the private Notifiable interface.
Notifiable * parent_
Where to proxy notifications.
Notifiable * NewCallback(Notifiable *parent)
Creates a new callback.
A Notifiable for synchronously waiting for a notification.
void notify() override
Implementation of notification receive.
void wait_for_notification()
Blocks the current thread until the notification is delivered.
OSSem sem_
Semaphore helping the implementation.
SyncNotifiable()
Constructor.
A notifiable class that calls a particular function object once when it is invoked,...
TempNotifiable(std::function< void()> body)
Constructor.
std::function< void()> body_
Function object (callback) to call.
void notify() OVERRIDE
Calls the notification method.
#define OVERRIDE
Function attribute for virtual functions declaring that this funciton is overriding a funciton that s...
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
#define DIE(MSG)
Unconditionally terminates the current process with a message.
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.