Sha256: 971f8d0b521b599a8f8938bf144a06ece5c34bcedbfc4bf949ea5590e769076a
Contents?: true
Size: 817 Bytes
Versions: 1
Compression:
Stored size: 817 Bytes
Contents
class Future { @@thread_pool = nil @@pool_size = 10 WaitInterval = 0.1 def Future pool: n { @@pool_size = match n { case 0 -> 10 case _ -> n } } def Future join! { @@thread_pool join } def initialize: @block { { @@thread_pool = ThreadPool new: @@pool_size } unless: @@thread_pool @@thread_pool execute: @block } def when_done: block { Future new: { block call: [value] } } def && block { when_done: block } def value { { Thread sleep: WaitInterval } until: { @block complete? } @block completed_value } } class FutureCollection { include: FancyEnumerable def initialize: @futures { } def each: block { @futures each: |f| { f when_done: block } } def await_all { @futures each: 'value } }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fancy-0.3.3 | lib/future.fy |