Skip to content

Commit

Permalink
Update documentation for SingleThreadedSchedulerClient() to specify t…
Browse files Browse the repository at this point in the history
…he memory model
  • Loading branch information
skeees authored and furszy committed Apr 3, 2021
1 parent 4ea2048 commit cb9bb25
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,13 @@ class CScheduler

/**
* Class used by CScheduler clients which may schedule multiple jobs
* which are required to be run serially. Does not require such jobs
* to be executed on the same thread, but no two jobs will be executed
* at the same time.
* which are required to be run serially. Jobs may not be run on the
* same thread, but no two jobs will be executed
* at the same time and memory will be release-acquire consistent
* (the scheduler will internally do an acquire before invoking a callback
* as well as a release at the end). In practice this means that a callback
* B() will be able to observe all of the effects of callback A() which executed
* before it.
*/
class SingleThreadedSchedulerClient {
private:
Expand All @@ -104,6 +108,13 @@ class SingleThreadedSchedulerClient {

public:
explicit SingleThreadedSchedulerClient(CScheduler *pschedulerIn) : m_pscheduler(pschedulerIn) {}

/**
* Add a callback to be executed. Callbacks are executed serially
* and memory is release-acquire consistent between callback executions.
* Practially, this means that callbacks can behave as if they are executed
* in order by a single thread.
*/
void AddToProcessQueue(std::function<void (void)> func);

// Processes all remaining queue members on the calling thread, blocking until queue is empty
Expand Down

0 comments on commit cb9bb25

Please sign in to comment.