Commit graph

21 commits

Author SHA1 Message Date
Akira Takizawa
595a7bab23 Increment MIT Licence copyright header year on files modified in 2017 2018-01-03 02:26:56 +09:00
Matt Corallo
5a933cefcc Add an interface to get the queue depth out of CValidationInterface 2017-12-26 11:54:49 -05:00
MeshCollider
1a445343f6 scripted-diff: Replace #include "" with #include <> (ryanofsky)
-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-11-16 08:23:01 +13:00
practicalswift
64fb0ac016 Declare single-argument (non-converting) constructors "explicit"
In order to avoid unintended implicit conversions.
2017-08-16 16:33:25 +02:00
Matt Corallo
a56f8b0be3 Add missing lock in CScheduler::AreThreadsServicingQueue()
Not an actual bug as this is only used in asserts right now, but
nice to not have a missing lock.
2017-07-23 14:51:22 -04:00
Matt Corallo
1f668b6468 Expose if CScheduler is being serviced, assert its not in EmptyQueue 2017-07-10 21:08:19 -04:00
Matt Corallo
3192975f1d Flush CValidationInterface callbacks prior to destruction
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-07 12:55:57 -04:00
Matt Corallo
08096bbbc6 Support more than one CScheduler thread for serial clients
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-07 11:33:18 -04:00
Matt Corallo
888cce57a6 Add perf counter data to GetStrongRandBytes state in scheduler 2017-05-22 16:01:52 -04:00
Cory Fields
e025246fe2 scheduler: fix sub-second precision with boost < 1.50 2017-03-31 11:54:58 -04:00
Matt Corallo
73296f54d6 CScheduler boost->std::function, use millisecs for times, not secs 2017-03-06 18:33:50 -05:00
isle2983
27765b6403 Increment MIT Licence copyright header year on files modified in 2016
Edited via:

$ contrib/devtools/copyright_header.py update .
2016-12-31 11:01:21 -07:00
Wladimir J. van der Laan
12519bf62b test: Fix use-after-free in scheduler tests
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-11-18 13:10:52 +01:00
Pavel Janík
166e4b0dfa Notify other serviceQueue thread we are finished to prevent deadlocks. 2016-05-06 20:44:40 +02:00
Casey Rodarmor
86270c8164 Replace boost::reverse_lock with our own. 2015-09-03 15:13:40 -04:00
Casey Rodarmor
fb08d92312 Make sure we re-acquire lock if a task throws 2015-08-18 10:40:13 -04:00
Cory Fields
72bf90d770 Fix scheduler build with some boost versions.
Some boost versions have a conflicting overload of wait_until that returns void.
Explicitly use a template here to avoid hitting that overload.
2015-06-15 16:29:57 -04:00
Wladimir J. van der Laan
bdcf5dea7c Fix intermittent hang issue in scheduler_tests
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-21 19:07:10 +02:00
Gavin Andresen
f50105486f
More robust CScheduler unit test
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-16 17:59:23 -04:00
Cory Fields
cfefe5b88c
scheduler: fix with boost <= 1.50 2015-05-14 10:37:19 -04:00
Gavin Andresen
928b950e3b
CScheduler class for lightweight task scheduling
Simple class to manage a task queue that is serviced by one or
more threads.
2015-05-14 10:37:19 -04:00