aboutsummaryrefslogtreecommitdiff
path: root/src/scheduler.cpp
AgeCommit message (Collapse)Author
2017-07-23Add missing lock in CScheduler::AreThreadsServicingQueue()Matt Corallo
Not an actual bug as this is only used in asserts right now, but nice to not have a missing lock.
2017-07-10Expose if CScheduler is being serviced, assert its not in EmptyQueueMatt Corallo
2017-07-07Flush CValidationInterface callbacks prior to destructionMatt Corallo
Note that the CScheduler thread cant be running at this point, it has already been stopped with the rest of the init threadgroup. Thus, just calling any remaining loose callbacks during Shutdown() is sane.
2017-07-07Support more than one CScheduler thread for serial clientsMatt Corallo
This will be used by CValidationInterface soon. This requires a bit of work as we need to ensure that most of our callbacks happen in-order (to avoid synchronization issues in wallet) - we keep our own internal queue and push things onto it, scheduling a queue-draining function immediately upon new callbacks.
2017-05-22Add perf counter data to GetStrongRandBytes state in schedulerMatt Corallo
2017-03-31scheduler: fix sub-second precision with boost < 1.50Cory Fields
2017-03-06CScheduler boost->std::function, use millisecs for times, not secsMatt Corallo
2016-12-31Increment MIT Licence copyright header year on files modified in 2016isle2983
Edited via: $ contrib/devtools/copyright_header.py update .
2016-11-18test: Fix use-after-free in scheduler testsWladimir J. van der Laan
Make a copy of the boost time-point to wait for, otherwise the head of the queue may be deleted by another thread while this one is waiting, while the boost function still has a reference to it. Although this problem is in non-test code, this is not an actual problem outside of the tests because we use the thread scheduler with only one service thread, so there will never be threads fighting at the head of the queue. The old boost fallback escapes this problem because it passes a scalar value to wait_until instead of a const object reference. Found by running the tests in LLVM-4.0-master asan.
2016-05-06Notify other serviceQueue thread we are finished to prevent deadlocks.Pavel Janík
2015-09-03Replace boost::reverse_lock with our own.Casey Rodarmor
2015-08-18Make sure we re-acquire lock if a task throwsCasey Rodarmor
2015-06-15Fix scheduler build with some boost versions.Cory Fields
Some boost versions have a conflicting overload of wait_until that returns void. Explicitly use a template here to avoid hitting that overload.
2015-05-21Fix intermittent hang issue in scheduler_testsWladimir J. van der Laan
Don't clear `stopRequested` and `stopWhenEmpty` at the top of `serviceQueue`, as this results in a race condition: on systems under heavy load, some of the threads only get scheduled on the CPU when the other threads have already finished their work. This causes the flags to be cleared post-hoc and thus those threads to wait forever. The potential drawback of this change is that the scheduler cannot be restarted after being stopped (an explicit reset would be needed), but we don't use this functionality anyway.
2015-05-16More robust CScheduler unit testGavin Andresen
On a busy or slow system, the CScheduler unit test could fail because it assumed all threads would be done after a couple of milliseconds. Replace the hard-coded sleep with CScheduler stop() method that will cleanly exit the servicing threads when all tasks are completely finished.
2015-05-14scheduler: fix with boost <= 1.50Cory Fields
2015-05-14CScheduler class for lightweight task schedulingGavin Andresen
Simple class to manage a task queue that is serviced by one or more threads.