Class: Crimson::AbortSignal

Inherits:
Object
  • Object
show all
Defined in:
lib/crimson/agent.rb

Overview

Thread-safe abort signal for cancelling tool execution mid-flight.

Instance Method Summary collapse

Constructor Details

#initializeAbortSignal

Returns a new instance of AbortSignal.



9
10
11
12
# File 'lib/crimson/agent.rb', line 9

def initialize
  @aborted = false
  @mutex = Mutex.new
end

Instance Method Details

#abort!void

This method returns an undefined value.

Mark as aborted.



16
17
18
# File 'lib/crimson/agent.rb', line 16

def abort!
  @mutex.synchronize { @aborted = true }
end

#aborted?Boolean

Returns whether abort has been requested.

Returns:

  • (Boolean)

    whether abort has been requested



21
22
23
# File 'lib/crimson/agent.rb', line 21

def aborted?
  @mutex.synchronize { @aborted }
end

#resetvoid

This method returns an undefined value.

Reset abort state.



27
28
29
# File 'lib/crimson/agent.rb', line 27

def reset
  @mutex.synchronize { @aborted = false }
end