Sha256: 369e3dee2fae1162df71eb225df06ae4698da4990ab620c9c684e7b9a2534ae9
Contents?: true
Size: 811 Bytes
Versions: 1
Compression:
Stored size: 811 Bytes
Contents
require 'thread' require 'concurrent/global_thread_pool' require 'concurrent/obligation' require 'concurrent/utilities' module Concurrent class Future include Obligation include UsesGlobalThreadPool behavior(:future) def initialize(*args, &block) unless block_given? @state = :fulfilled else @value = nil @state = :pending Future.thread_pool.post(*args) do work(*args, &block) end end end private # @private def work(*args) # :nodoc: mutex.synchronize do begin @value = yield(*args) @state = :fulfilled rescue Exception => ex @state = :rejected @reason = ex end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
concurrent-ruby-0.2.1 | lib/concurrent/future.rb |