Class: Thread

Inherits:
Object
  • Object
show all
Includes:
Delayer::Deferred::Deferredable::Awaitable
Defined in:
lib/delayer/deferred/thread.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Delayer::Deferred::Deferredable::Awaitable

#+@, #enter_await, #exit_await

Class Method Details

.delayerObject



8
9
10
# File 'lib/delayer/deferred/thread.rb', line 8

def self.delayer
  Delayer
end

Instance Method Details

#add_child(chainable, name: caller_locations(1,1).first.to_s) ⇒ Object



30
31
32
# File 'lib/delayer/deferred/thread.rb', line 30

def add_child(chainable, name: caller_locations(1,1).first.to_s)
  __gen_promise(name).add_child(chainable)
end

#next(name: caller_locations(1,1).first.to_s, &proc) ⇒ Object Also known as: deferred

このDeferredが成功した場合の処理を追加する。 新しいDeferredのインスタンスを返す。 このメソッドはスレッドセーフです。 TODO: procが空のとき例外を発生させる



16
17
18
# File 'lib/delayer/deferred/thread.rb', line 16

def next(name: caller_locations(1,1).first.to_s, &proc)
  add_child(Delayer::Deferred::Chain::Next.new(&proc), name: name)
end

#trap(name: caller_locations(1,1).first.to_s, &proc) ⇒ Object Also known as: error

このDeferredが失敗した場合の処理を追加する。 新しいDeferredのインスタンスを返す。 このメソッドはスレッドセーフです。 TODO: procが空のとき例外を発生させる



25
26
27
# File 'lib/delayer/deferred/thread.rb', line 25

def trap(name: caller_locations(1,1).first.to_s, &proc)
  add_child(Delayer::Deferred::Chain::Trap.new(&proc), name: name)
end