Skip to main content

Module hooks

Module hooks 

Source
Expand description

Thread-safe filesystem test hooks.

§Design Architecture & Invariants

  • Hooks<'a> & HooksHandle: Hooks<'a> is the exclusive mutator handle bound to lifetime 'a (the test context). HooksHandle is shared via Arc by FxFilesystem options to invoke registered test callbacks (on_* methods) during transaction commits.

  • Lifetime Safety: Incoming hook closures bound to lifetime 'a are transmuted to 'static and stored inside HooksInner. Hooks<'a> holds the primary Arc<HooksInner>, while HooksHandle holds a Weak<HooksInner>.

  • Cleanup & Synchronization: When Hooks<'a> drops, it drops its Arc<HooksInner> and waits for a message on an mpsc channel. Active readers (on_* methods) temporarily upgrade the Weak reference to an Arc, ensuring HooksInner remains valid during callback execution. When all readers finish and HooksInner drops, SendOnDrop (the last field of HooksInner) drops after HooksTable, sending the completion signal to detach().

Structs§

Hooks
Used to register test hooks for an FxFilesystem.
HooksHandle
Handle stored on FxFilesystem options to trigger registered test hooks.