Skip to content

Commit 93ba327

Browse files
author
dave
committed
#23 make execute have been queue behaviour.
1 parent ebaaf4b commit 93ba327

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/TaskManagerIO.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,33 @@ class TaskManager {
108108

109109
/**
110110
* Executes a task manager task as soon as possible. Useful to add work into task manager from another thread of
111-
* execution. Shorthand for scheduleOnce(0, task);
111+
* execution. Shorthand for scheduleOnce(2, task);
112+
*
113+
* Why not scheduleOnce with 0 you may ask, taskManager is cooperative which also means it is an unfair scheduler.
114+
* Given this, it would always add at the front of the queue if the time was 0, but by making the time 2, we ensure
115+
* it is queued behind other things needing immediate execution.
116+
*
112117
* @param workToDo the work to be done
113118
* @return the task ID that can be queried and cancelled.
114119
*/
115120
inline taskid_t execute(TimerFn workToDo) {
116-
return scheduleOnce(0, workToDo);
121+
return scheduleOnce(2, workToDo, TIME_MICROS);
117122
}
118123

119124
/**
120125
* Executes a task manager task as soon as possible. Useful to add work into task manager from another thread of
121-
* execution. Shorthand for scheduleOnce(0, task);
126+
* execution. Shorthand for scheduleOnce(2, task);
127+
*
128+
* Why not scheduleOnce with 0 you may ask, taskManager is cooperative which also means it is an unfair scheduler.
129+
* Given this, it would always add at the front of the queue if the time was 0, but by making the time 2, we ensure
130+
* it is queued behind other things needing immediate execution.
131+
*
122132
* @param execToDo the work to be done
123133
* @param deleteWhenDone default to false, task manager will reclaim the memory when done with this executable.
124134
* @return the task ID that can be queried and cancelled.
125135
*/
126136
inline taskid_t execute(Executable* execToDo, bool deleteWhenDone = false) {
127-
return scheduleOnce(0, execToDo, TIME_MICROS, deleteWhenDone);
137+
return scheduleOnce(2, execToDo, TIME_MICROS, deleteWhenDone);
128138
}
129139

130140
/**

0 commit comments

Comments
 (0)