1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
/**
| Alternate registration functions that release
| a shared_ptr after the last notification is
| sent. These are useful for race-free cleanup,
| since unregistration is nonblocking and can
| return before the last notification is
| processed.
*/
crate::ix!();
//-------------------------------------------[.cpp/bitcoin/src/validationinterface.cpp]
/**
| Register subscriber
|
*/
pub fn register_shared_validation_interface(callbacks: Arc<dyn ValidationInterface>) {
todo!();
/*
// Each connection captures the shared_ptr to ensure that each callback is
// executed before the subscriber is destroyed. For more details see #18338.
g_signals.m_internals->Register(std::move(callbacks));
*/
}
/**
| Register subscriber
|
*/
pub fn register_validation_interface(callbacks: Arc<Mutex<dyn ValidationInterface>>) {
todo!();
/*
// Create a shared_ptr with a no-op deleter - CValidationInterface lifecycle
// is managed by the caller.
RegisterSharedValidationInterface({callbacks, [](CValidationInterface*){}});
*/
}
/**
| Unregister subscriber
|
*/
pub fn unregister_shared_validation_interface(callbacks: Arc<dyn ValidationInterface>) {
todo!();
/*
UnregisterValidationInterface(callbacks.get());
*/
}
/**
| Unregister subscriber. DEPRECATED.
| This is not safe to use when the RPC server
| or main message handler thread is running.
|
*/
pub fn unregister_validation_interface(callbacks: Arc<Mutex<dyn ValidationInterface>>) {
todo!();
/*
if (g_signals.m_internals) {
g_signals.m_internals->Unregister(callbacks);
}
*/
}
/**
| Unregister all subscribers
|
*/
pub fn unregister_all_validation_interfaces() {
todo!();
/*
if (!g_signals.m_internals) {
return;
}
g_signals.m_internals->Clear();
*/
}
/**
| Pushes a function to callback onto the
| notification queue, guaranteeing
| any callbacks generated prior to now
| are finished when the function is called.
|
| Be very careful blocking on func to be
| called if any locks are held - validation
| interface clients may not be able to
| make progress as they often wait for
| things like cs_main, so blocking until
| func is called with cs_main will result
| in a deadlock (that DEBUG_LOCKORDER
| will miss).
|
*/
pub fn call_function_in_validation_interface_queue(func: fn() -> ()) {
todo!();
/*
g_signals.m_internals->m_schedulerClient.AddToProcessQueue(std::move(func));
*/
}
/**
| This is a synonym for the following,
| which asserts certain locks are not
| held:
|
| std::promise<c_void> promise;
| CallFunctionInValidationInterfaceQueue([&promise] {
| promise.set_value();
| });
| promise.get_future().wait();
|
*/
#[LOCKS_EXCLUDED(cs_main)]
pub fn sync_with_validation_interface_queue() {
todo!();
/*
AssertLockNotHeld(cs_main);
// Block until the validation queue drains
std::promise<c_void> promise;
CallFunctionInValidationInterfaceQueue([&promise] {
promise.set_value();
});
promise.get_future().wait();
*/
}