aboutsummaryrefslogtreecommitdiff
path: root/src/scheduler.h
AgeCommit message (Collapse)Author
2024-02-16kernel: Remove dependency on CSchedulerTheCharlatan
By defining a virtual interface class for the scheduler client, users of the kernel can now define their own event consuming infrastructure, without having to spawn threads or rely on the scheduler design. Removing CScheduler also allows removing the thread and exception modules from the kernel library.
2024-02-15scripted-diff: Rename SingleThreadedSchedulerClient to SerialTaskRunnerTheCharlatan
-BEGIN VERIFY SCRIPT- s() { git grep -l "$1" src | (grep -v "$3" || cat;) | xargs sed -i "s/$1/$2/g"; } s 'SingleThreadedSchedulerClient' 'SerialTaskRunner' '' s 'SinglethreadedSchedulerClient' 'SerialTaskRunner' '' s 'm_schedulerClient' 'm_task_runner' '' s 'AddToProcessQueue' 'insert' '' s 'EmptyQueue' 'flush' '' s 'CallbacksPending' 'size' 'validation' sed -i '109s/CallbacksPending/size/' src/validationinterface.cpp -END VERIFY SCRIPT- Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
2022-12-24scripted-diff: Bump copyright headersHennadii Stepanov
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: - 2021: f47dda2c58b5d8d623e0e7ff4e74bc352dfa83d7 - 2020: fa0074e2d82928016a43ca408717154a1c70a4db - 2019: aaaaad6ac95b402fe18d019d67897ced6b316ee0
2022-05-12Increase threadsafety annotation coverageAnthony Towns
2022-05-10Switch scheduler to steady_clockMacroFake
2022-04-30Pass lifetimebound reference to SingleThreadedSchedulerClientMacroFake
2022-01-14refactor: replace RecursiveMutex `m_callbacks_mutex` with MutexSebastian Falbesoner
In each of the critical sections, only the the guarded variables are accessed, without any chance that within one section another one is called. Hence, we can use an ordinary Mutex instead of RecursiveMutex.
2022-01-14scripted-diff: rename `m_cs_callbacks_pending` -> `m_callbacks_mutex`Sebastian Falbesoner
-BEGIN VERIFY SCRIPT- sed -i 's/m_cs_callbacks_pending/m_callbacks_mutex/g' ./src/scheduler.h ./src/scheduler.cpp -END VERIFY SCRIPT
2021-12-30scripted-diff: Bump copyright headersHennadii Stepanov
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: * 2020: fa0074e2d82928016a43ca408717154a1c70a4db * 2019: aaaaad6ac95b402fe18d019d67897ced6b316ee0
2021-11-16doc: Fix typos in endif header commentsMarcoFalke
2021-01-29refactor: remove boost::thread_group usagefanquake
2020-06-21clang-format schedulerMarcoFalke
Can easily be reviewed with the git options --ignore-all-space --word-diff-regex=. -U0
2020-05-28doc: Switch scheduler to doxygen commentsMarcoFalke
2020-05-28scheduler: Replace stop(true) with StopWhenDrained()MarcoFalke
This helps understanding the code at the call site without having to look up the name of the argument or the default value.
2020-05-28doc: Remove unused documentation about unimplemented featuresMarcoFalke
2020-05-28doc: Switch boost::thread to std::thread in schedulerMarcoFalke
After commit d0ebd93 the scheduler itself no longer cares if the serviceQueue is run in a std::thread or boost::thread. Change the documentation to std::thread because we switched to C++11.
2020-03-10scheduler: Make schedule* methods type safeMarcoFalke
2020-03-07scheduler: Use C++11 member initialization, add shutdown assertMarcoFalke
"Initializing the members in the declaration makes it easy to spot uninitialized ones". https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#c-data-structures
2020-03-06scheduler: switch from boost to stdAnthony Towns
Changes from boost::chrono to std::chrono, boost::condition_var to std::condition_var, boost::mutex to sync.h Mutex, and reverselock.h to sync.h REVERSE_LOCK. Also adds threadsafety annotations to CScheduler members.
2020-02-13[util] allow scheduler to be mockedAmiti Uttarwar
Add MockForward method to the scheduler that mimics going into the future by rescheduling all items on the taskQueue to be sooner.
2020-01-15scripted-diff: Bump copyright of files changed in 2020MarcoFalke
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
2020-01-15scripted-diff: Replace CCriticalSection with RecursiveMutexMarcoFalke
-BEGIN VERIFY SCRIPT- # Delete outdated alias for RecursiveMutex sed -i -e '/CCriticalSection/d' ./src/sync.h # Replace use of outdated alias with RecursiveMutex sed -i -e 's/CCriticalSection/RecursiveMutex/g' $(git grep -l CCriticalSection) -END VERIFY SCRIPT-
2019-12-30scripted-diff: Bump copyright of files changed in 2019MarcoFalke
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
2019-02-10trivial: correct parameter name in commentsandrewtoth
2018-10-20scripted-diff: Replace boost::bind with std::bindChun Kuan Lee
-BEGIN VERIFY SCRIPT- for j in $(seq 1 5) do sed -i "s/ _${j}/ std::placeholders::_${j}/g" $(git grep --name-only " _${j}" -- '*.cpp' '*.h') done sed -i "s/boost::bind/std::bind/g" $(git grep --name-only boost::bind -- '*.cpp' '*.h') sed -i "s/boost::ref/std::ref/g" $(git grep --name-only boost::ref -- '*.cpp' '*.h') sed -i '/boost\/bind/d' $(git grep --name-only boost/bind) -END VERIFY SCRIPT-
2018-09-13convert C-style (void) parameter lists to C++ style ()Arvid Norberg
2018-09-04Fix typos reported by codespellpracticalswift
2018-08-08Merge #13780: 0.17: Pre-branch maintenanceWladimir J. van der Laan
3fc20632a3ad30809356a58d2cf0ea4a4ad4cec3 qt: Set BLOCK_CHAIN_SIZE = 220 (DrahtBot) 2b6a2f4a28792f2fe9dc1be843b1ff1ecae35e8a Regenerate manpages (DrahtBot) eb7daf4d600eeb631427c018a984a77a34aca66e Update copyright headers to 2018 (DrahtBot) Pull request description: Some trivial maintenance to avoid having to do it again after the 0.17 branch off. (The scripts to do this are in `./contrib/`) Tree-SHA512: 16b2af45e0351b1c691c5311d48025dc6828079e98c2aa2e600dc5910ee8aa01858ca6c356538150dc46fe14c8819ed8ec8e4ec9a0f682b9950dd41bc50518fa
2018-08-01[trivial,doc] Fix memory consistency model in commentJesse Cohen
2018-07-31Merge #13247: Add tests to SingleThreadedSchedulerClient() and document the ↵MarcoFalke
memory model cbeaa91dbb Update ValidationInterface() documentation to explicitly specify threading and memory model (Jesse Cohen) b296b425a7 Update documentation for SingleThreadedSchedulerClient() to specify the memory model (Jesse Cohen) 9994d01d8b Add Unit Test for SingleThreadedSchedulerClient (Jesse Cohen) Pull request description: As discussed in #13023 I've split this test out into a separate pr This test (and documentation update) makes explicit the guarantee (previously undefined, but implied by the 'SingleThreaded' in `SingleThreadedSchedulerClient()`) - that callbacks pushed to the `SingleThreadedSchedulerClient()` obey the single threaded model for memory and execution - specifically, the callbacks are executed fully and in order, and even in cases where a subsequent callback is executed by a different thread, sequential consistency of memory for all threads executing these callbacks is maintained. Maintaining memory consistency should make the api more developer friendly - especially for users of the validationinterface. To the extent that there are performance implications from this decision, these are not currently present in practice because all use of this scheduler happens on a single thread currently, furthermore the lock should guarantee consistency across callback executions even when callbacks are executed by multiple threads (as the test does). Tree-SHA512: 5d95a7682c402e5ad76b05bc9dfbca99ca64105f62ab9e78f6fc0f6ea8c5277aa399fbb94298e35cc677b0c2181ff17259584bb7ae230e38aa68b85ecbc22856
2018-07-30Update documentation for SingleThreadedSchedulerClient() to specify the ↵Jesse Cohen
memory model
2018-07-27Update copyright headers to 2018DrahtBot
2018-04-30scheduler: Add Clang thread safety annotations for variables guarded by ↵practicalswift
m_cs_callbacks_pending
2018-01-03Increment MIT Licence copyright header year on files modified in 2017Akira Takizawa
2017-12-26Add an interface to get the queue depth out of CValidationInterfaceMatt Corallo
2017-11-16scripted-diff: Replace #include "" with #include <> (ryanofsky)MeshCollider
-BEGIN VERIFY SCRIPT- for f in \ src/*.cpp \ src/*.h \ src/bench/*.cpp \ src/bench/*.h \ src/compat/*.cpp \ src/compat/*.h \ src/consensus/*.cpp \ src/consensus/*.h \ src/crypto/*.cpp \ src/crypto/*.h \ src/crypto/ctaes/*.h \ src/policy/*.cpp \ src/policy/*.h \ src/primitives/*.cpp \ src/primitives/*.h \ src/qt/*.cpp \ src/qt/*.h \ src/qt/test/*.cpp \ src/qt/test/*.h \ src/rpc/*.cpp \ src/rpc/*.h \ src/script/*.cpp \ src/script/*.h \ src/support/*.cpp \ src/support/*.h \ src/support/allocators/*.h \ src/test/*.cpp \ src/test/*.h \ src/wallet/*.cpp \ src/wallet/*.h \ src/wallet/test/*.cpp \ src/wallet/test/*.h \ src/zmq/*.cpp \ src/zmq/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT-
2017-08-16Declare single-argument (non-converting) constructors "explicit"practicalswift
In order to avoid unintended implicit conversions.
2017-07-25Add const to methods that do not modify the object for which it is calledpracticalswift
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-07-07Add default arg to CScheduler to schedule() a callback nowMatt Corallo
2017-05-13Replace boost::function with std::function (C++11)practicalswift
2017-03-06CScheduler boost->std::function, use millisecs for times, not secsMatt Corallo
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-14CScheduler class for lightweight task schedulingGavin Andresen
Simple class to manage a task queue that is serviced by one or more threads.