Module: Going

Defined in:
lib/going.rb,
lib/going/channel.rb,
lib/going/version.rb,
lib/going/operation.rb,
lib/going/select_helper.rb,
lib/going/operation/push.rb,
lib/going/operation/shift.rb,
lib/going/select_statement.rb,
lib/going/boolean_attr_reader.rb,
lib/going/nil_select_statement.rb

Defined Under Namespace

Modules: BooleanAttrReader Classes: Channel, NilSelectStatement, Operation, Push, SelectHelper, SelectStatement, Shift

Constant Summary collapse

VERSION =
'1.1.0'

Class Method Summary collapse

Class Method Details

.go(*args, &blk) ⇒ Object

Creates an async thread to run the block



18
19
20
# File 'lib/going.rb', line 18

def self.go(*args, &blk)
  Thread.new(*args, &blk)
end

.select(&blk) ⇒ Object

Creates a synchronous block that will select the first channel operation to complete. Only one operation inside the block will complete and any operations that are incomplete will be removed afterwards.



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/going.rb', line 28

def self.select(&blk)
  fail 'a block must be passed' unless block_given?

  select = SelectStatement.new_instance
  select.select(&blk)
  SelectStatement.reset

  select.call_completion_block

  nil
end