Skip to content

Commit fa3d41b

Browse files
author
MarcoFalke
committed
doc: Switch scheduler to doxygen comments
1 parent fac43f9 commit fa3d41b

File tree

1 file changed

+31
-25
lines changed

1 file changed

+31
-25
lines changed

src/scheduler.h

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@
1212

1313
#include <sync.h>
1414

15-
//
16-
// Simple class for background tasks that should be run
17-
// periodically or once "after a while"
18-
//
19-
// Usage:
20-
//
21-
// CScheduler* s = new CScheduler();
22-
// s->scheduleFromNow(doSomething, std::chrono::milliseconds{11}); // Assuming a: void doSomething() { }
23-
// s->scheduleFromNow([=] { this->func(argument); }, std::chrono::milliseconds{3});
24-
// std::thread* t = new std::thread([&] { s->serviceQueue(); });
25-
//
26-
// ... then at program shutdown, make sure to call stop() to clean up the thread(s) running serviceQueue:
27-
// s->stop();
28-
// t->join();
29-
// delete t;
30-
// delete s; // Must be done after thread is interrupted/joined.
31-
//
15+
/**
16+
* Simple class for background tasks that should be run
17+
* periodically or once "after a while"
18+
*
19+
* Usage:
20+
*
21+
* CScheduler* s = new CScheduler();
22+
* s->scheduleFromNow(doSomething, std::chrono::milliseconds{11}); // Assuming a: void doSomething() { }
23+
* s->scheduleFromNow([=] { this->func(argument); }, std::chrono::milliseconds{3});
24+
* std::thread* t = new std::thread([&] { s->serviceQueue(); });
25+
*
26+
* ... then at program shutdown, make sure to call stop() to clean up the thread(s) running serviceQueue:
27+
* s->stop();
28+
* t->join();
29+
* delete t;
30+
* delete s; // Must be done after thread is interrupted/joined.
31+
*/
3232
class CScheduler
3333
{
3434
public:
@@ -37,7 +37,7 @@ class CScheduler
3737

3838
typedef std::function<void()> Function;
3939

40-
// Call func at/after time t
40+
/** Call func at/after time t */
4141
void schedule(Function f, std::chrono::system_clock::time_point t);
4242

4343
/** Call f once after the delta has passed */
@@ -61,8 +61,10 @@ class CScheduler
6161
*/
6262
void MockForward(std::chrono::seconds delta_seconds);
6363

64-
// Services the queue 'forever'. Should be run in a thread,
65-
// and interrupted using boost::interrupt_thread
64+
/**
65+
* Services the queue 'forever'. Should be run in a thread,
66+
* and interrupted using boost::interrupt_thread
67+
*/
6668
void serviceQueue();
6769

6870
/** Tell any threads running serviceQueue to stop as soon as the current task is done */
@@ -78,12 +80,14 @@ class CScheduler
7880
newTaskScheduled.notify_all();
7981
}
8082

81-
// Returns number of tasks waiting to be serviced,
82-
// and first and last task times
83+
/**
84+
* Returns number of tasks waiting to be serviced,
85+
* and first and last task times
86+
*/
8387
size_t getQueueInfo(std::chrono::system_clock::time_point &first,
8488
std::chrono::system_clock::time_point &last) const;
8589

86-
// Returns true if there are threads actively running in serviceQueue()
90+
/** Returns true if there are threads actively running in serviceQueue() */
8791
bool AreThreadsServicingQueue() const;
8892

8993
private:
@@ -128,8 +132,10 @@ class SingleThreadedSchedulerClient {
128132
*/
129133
void AddToProcessQueue(std::function<void ()> func);
130134

131-
// Processes all remaining queue members on the calling thread, blocking until queue is empty
132-
// Must be called after the CScheduler has no remaining processing threads!
135+
/**
136+
* Processes all remaining queue members on the calling thread, blocking until queue is empty
137+
* Must be called after the CScheduler has no remaining processing threads!
138+
*/
133139
void EmptyQueue();
134140

135141
size_t CallbacksPending();

0 commit comments

Comments
 (0)