aboutsummaryrefslogtreecommitdiff
path: root/src/validationinterface.h
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2018-07-31 20:50:18 -0400
committerMarcoFalke <falke.marco@gmail.com>2018-07-31 20:52:05 -0400
commite83d82a85c53196aff5b5ac500f20bb2940663fa (patch)
treec58c2d14bdcc61e149d2b5739de0eb5034820d8a /src/validationinterface.h
parent0fb9c87815d180031b7924607946e51f860c3ba8 (diff)
parentcbeaa91dbb1bc3ee6c05f3ee55a71268b8db2035 (diff)
downloadbitcoin-e83d82a85c53196aff5b5ac500f20bb2940663fa.tar.xz
Merge #13247: Add tests to SingleThreadedSchedulerClient() and document the 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
Diffstat (limited to 'src/validationinterface.h')
-rw-r--r--src/validationinterface.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/validationinterface.h b/src/validationinterface.h
index 42cc2e9a20..bddc28d24a 100644
--- a/src/validationinterface.h
+++ b/src/validationinterface.h
@@ -53,6 +53,21 @@ void CallFunctionInValidationInterfaceQueue(std::function<void ()> func);
*/
void SyncWithValidationInterfaceQueue();
+/**
+ * Implement this to subscribe to events generated in validation
+ *
+ * Each CValidationInterface() subscriber will receive event callbacks
+ * in the order in which the events were generated by validation.
+ * Furthermore, each ValidationInterface() subscriber may assume that
+ * callbacks effectively run in a single thread with single-threaded
+ * memory consistency. That is, for a given ValidationInterface()
+ * instantiation, each callback will complete before the next one is
+ * invoked. This means, for example when a block is connected that the
+ * UpdatedBlockTip() callback may depend on an operation performed in
+ * the BlockConnected() callback without worrying about explicit
+ * synchronization. No ordering should be assumed across
+ * ValidationInterface() subscribers.
+ */
class CValidationInterface {
protected:
/**