This commit is contained in:
Silviu Caragea 2017-12-15 16:44:54 +02:00 committed by alexey-milovidov
parent 99a19de80e
commit b08463ed7b
3 changed files with 4 additions and 9 deletions

View File

@ -59,12 +59,7 @@ bool BackgroundSchedulePool::TaskInfo::schedule()
bool BackgroundSchedulePool::TaskInfo::scheduleAfter(size_t ms)
{
std::lock_guard lock(mutex);
if (deactivated || scheduled)
return false;
pool.scheduleDelayedTask(shared_from_this(), ms, lock);
pool.scheduleDelayedTask(shared_from_this(), ms);
return true;
}
@ -160,7 +155,7 @@ void BackgroundSchedulePool::removeTask(const TaskHandle & task)
}
void BackgroundSchedulePool::scheduleDelayedTask(const TaskHandle & task, size_t ms, std::lock_guard<std::recursive_mutex> &)
void BackgroundSchedulePool::scheduleDelayedTask(const TaskHandle & task, size_t ms)
{
Poco::Timestamp current_time;

View File

@ -90,7 +90,7 @@ private:
void delayExecutionThreadFunction();
/// Schedule task for execution after specified delay from now.
void scheduleDelayedTask(const TaskHandle & task, size_t ms, std::lock_guard<std::recursive_mutex> &);
void scheduleDelayedTask(const TaskHandle & task, size_t ms);
/// Remove task, that was scheduled with delay, from schedule.
void cancelDelayedTask(const TaskHandle & task, std::lock_guard<std::recursive_mutex> &);

View File

@ -206,7 +206,7 @@ WatchCallback ZooKeeper::callbackForTaskHandle(const TaskHandlePtr & task)
{
if (t)
{
t->schedule();
t->scheduleAfter(0);
t.reset(); /// The event is set only once, even if the callback can fire multiple times due to session events.
}
};