Class: TIMEx::Strategies::Closeable

Inherits:
Base
  • Object
show all
Defined in:
lib/timex/strategies/closeable.rb

Overview

Note:

close_method runs concurrently with the user block. It must be safe to call while the block uses the resource; avoid mutual deadlocks on the same mutex.

Invokes close_method on a watchdog thread after the deadline so blocking I/O surfaces as IOError / EBADF / EPIPE (etc.), then maps those to Expired when the close was timer-driven.

See Also:

Instance Method Summary collapse

Methods inherited from Base

call, #call

Constructor Details

#initialize(resource:, close_method: :close) ⇒ Closeable

Returns a new instance of Closeable.

Parameters:

  • resource (Object)

    object receiving close_method

  • close_method (Symbol) (defaults to: :close)

    method name invoked to unblock I/O



18
19
20
21
22
# File 'lib/timex/strategies/closeable.rb', line 18

def initialize(resource:, close_method: :close)
  super()
  @resource     = resource
  @close_method = close_method
end