Details
-
Improvement
-
Resolution: Unresolved
-
Major
-
None
-
1
Description
Snoozing a global task currently takes a double of seconds
GlobalTask::snooze(const double secs)
|
and internally compares to INT_MAX, to indicate "sleep forever".
if (secs == INT_MAX) {
|
setState(TASK_SNOOZED, TASK_RUNNING);
|
updateWaketime(std::chrono::steady_clock::time_point::max());
|
return;
|
}
|
Therefore, many callers provide INT_MAX or std::numeric_limits<int>::max(), which is converted to a double, then compared against an int.
This leaves the possibility of typos (e.g., UINT_MAX, std::numeric_limits<size_t>::max()), and requires the caller to handle the units (seconds vs milliseconds etc).
The interface could be improved with by taking a duration, e.g.,
GlobalTask::snooze(std::chrono::steady_clock::duration sleepTime)
|
Attachments
Gerrit Reviews
For Gerrit Dashboard: MB-51168 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
174155,4 | MB-51168: Add GlobalTask::snoozeUntil() | master | kv_engine | Status: NEW | +1 | +1 |
174156,4 | MB-51168: Implement GlobalTask::snooze(SnoozeTime) | master | kv_engine | Status: NEW | -1 | -1 |
174157,3 | MB-51168: Make NotifiableTask::sleepTime a duration | master | kv_engine | Status: NEW | +1 | +1 |
174158,4 | MB-51168: Add GlobalTask::snoozeForever() | master | kv_engine | Status: NEW | +1 | +1 |
174165,4 | MB-51168: Add duration snooze functions to ExecutorPools | master | kv_engine | Status: NEW | -1 | -1 |
174203,4 | MB-51168: Use SnoozeTime ExecutorPool::snooze() function | master | kv_engine | Status: NEW | -1 | -1 |
174204,4 | MB-51168: Remove double based ExecutorPool::snooze() functions | master | kv_engine | Status: NEW | +1 | +1 |
174240,3 | MB-51168: Refactor ReadyQueueMaintainsWakeTimeOrder | master | kv_engine | Status: NEW | +1 | +1 |
174241,4 | MB-51168: Add SnoozeTime based GlobalTask initialization functions | master | kv_engine | Status: NEW | -1 | -1 |
174242,4 | MB-51168: MockGlobalTask takes duration | master | kv_engine | Status: NEW | -1 | -1 |
174243,4 | MB-51168: Use durations in LambdaTask ctor | master | kv_engine | Status: NEW | -1 | -1 |
174260,2 | MB-51168: CheckpointMemRecoveryTask should not run every 5ns | master | kv_engine | Status: NEW | +1 | +1 |
174261,3 | MB-51168: Use SnoozeTime in NotifiableTasks | master | kv_engine | Status: NEW | -1 | -1 |
174295,2 | MB-51168: Use duration in VKeyStatBGFetchTask | master | kv_engine | Status: NEW | +1 | +1 |
174296,2 | MB-51168: Use duration in ItemPager | master | kv_engine | Status: NEW | -1 | -1 |
174297,2 | MB-51168: Use duration in AccessScanner ctor | master | kv_engine | Status: NEW | -1 | -1 |
174298,2 | MB-51168: Remove GlobalTask double sleeptime ctors | master | kv_engine | Status: NEW | -1 | -1 |
174325,6 | MB-51168: SnoozeTime class | master | kv_engine | Status: NEW | -1 | -1 |