Skip to content

Commit cb9bb25

Browse files
skeeesfurszy
authored andcommitted
Update documentation for SingleThreadedSchedulerClient() to specify the memory model
1 parent 4ea2048 commit cb9bb25

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/scheduler.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,13 @@ class CScheduler
8787

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

105109
public:
106110
explicit SingleThreadedSchedulerClient(CScheduler *pschedulerIn) : m_pscheduler(pschedulerIn) {}
111+
112+
/**
113+
* Add a callback to be executed. Callbacks are executed serially
114+
* and memory is release-acquire consistent between callback executions.
115+
* Practially, this means that callbacks can behave as if they are executed
116+
* in order by a single thread.
117+
*/
107118
void AddToProcessQueue(std::function<void (void)> func);
108119

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

0 commit comments

Comments
 (0)