Class: LLDB::Context
- Inherits:
-
Object
- Object
- LLDB::Context
- Defined in:
- lib/lldb/context.rb
Constant Summary collapse
- OPEN =
:open- CLOSING =
:closing- CLOSED =
:closed
Instance Method Summary collapse
- #close(except: nil) ⇒ Object
- #closed? ⇒ Boolean
- #closing? ⇒ Boolean
- #ensure_open! ⇒ Object
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #open? ⇒ Boolean
- #register(handle) ⇒ Object
- #state ⇒ Object
Constructor Details
Instance Method Details
#close(except: nil) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/lldb/context.rb', line 58 def close(except: nil) handles = @mutex.synchronize do next nil if @state == CLOSED || @state == CLOSING @state = CLOSING @handles.filter_map do |reference| begin handle = reference.__getobj__ handle unless handle.equal?(except) rescue WeakRef::RefError nil end end end return unless handles begin handles.each(&:close) ensure @mutex.synchronize { @state = CLOSED } end end |
#closing? ⇒ Boolean
42 43 44 |
# File 'lib/lldb/context.rb', line 42 def closing? state == CLOSING end |
#ensure_open! ⇒ Object
52 53 54 |
# File 'lib/lldb/context.rb', line 52 def ensure_open! raise ClosedObjectError, 'LLDB context is closed' unless open? end |
#register(handle) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/lldb/context.rb', line 22 def register(handle) @mutex.synchronize do raise LifecycleError, 'LLDB context is closed' unless @state == OPEN @handles << WeakRef.new(handle) end handle end |
#state ⇒ Object
32 33 34 |
# File 'lib/lldb/context.rb', line 32 def state @mutex.synchronize { @state } end |