Class: Clacky::CancelFlag
- Inherits:
-
Object
- Object
- Clacky::CancelFlag
- Defined in:
- lib/clacky/cancel_flag.rb
Overview
A one-way, thread-safe cancellation flag shared across a parent agent and the subagents it forks. Fan-out runs each subagent on its own worker thread; when the parent is interrupted the worker threads must learn to stop, but they cannot see the parent's thread-local task epoch. Flipping this flag is the shared signal every subagent polls at its safe checkpoints.
Instance Method Summary collapse
- #cancel! ⇒ Object
- #cancelled? ⇒ Boolean
-
#initialize ⇒ CancelFlag
constructor
A new instance of CancelFlag.
Constructor Details
#initialize ⇒ CancelFlag
Returns a new instance of CancelFlag.
10 11 12 13 |
# File 'lib/clacky/cancel_flag.rb', line 10 def initialize @mutex = Mutex.new @cancelled = false end |
Instance Method Details
#cancel! ⇒ Object
15 16 17 |
# File 'lib/clacky/cancel_flag.rb', line 15 def cancel! @mutex.synchronize { @cancelled = true } end |
#cancelled? ⇒ Boolean
19 20 21 |
# File 'lib/clacky/cancel_flag.rb', line 19 def cancelled? @mutex.synchronize { @cancelled } end |