Module: Emit
- Defined in:
- lib/emit.rb,
lib/emit/channel.rb,
lib/emit/process.rb,
lib/emit/version.rb,
lib/emit/scheduler.rb,
lib/emit/exceptions.rb,
lib/emit/alternation.rb,
lib/emit/channel_end.rb,
lib/emit/input_guard.rb,
lib/emit/output_guard.rb,
lib/emit/channel_request.rb,
lib/emit/channel_end_read.rb,
lib/emit/channel_end_write.rb
Defined Under Namespace
Classes: Alternation, Channel, ChannelPoisonedException, ChannelRetiredException, DeadlockException, InputGuard, MainProcess, OutputGuard, Process, Scheduler
Constant Summary
collapse
- VERSION =
"0.2.0"
Class Method Summary
collapse
Class Method Details
.channel ⇒ Object
40
41
42
|
# File 'lib/emit.rb', line 40
def channel
Channel.new
end
|
.choice(*guards) ⇒ Object
56
57
58
|
# File 'lib/emit.rb', line 56
def choice(*guards)
Alternation.new(guards).execute
end
|
.method_missing(name, *args, **kwargs) ⇒ Object
60
61
62
|
# File 'lib/emit.rb', line 60
def method_missing(name, *args, **kwargs)
Emit.process(*args, **kwargs, &method(name.to_sym))
end
|
.parallel(*processes, run: true) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/emit.rb', line 22
def parallel(*processes, run: true)
processes.flatten!
processes.each do |process|
process.start
Scheduler.enqueue(process)
end
if run
Scheduler.join(processes)
processes.map(&:return_value)
end
end
|
.poison(*channel_ends) ⇒ Object
48
49
50
|
# File 'lib/emit.rb', line 48
def poison(*channel_ends)
channel_ends.each(&:poison)
end
|
.process(*args, **kwargs, &block) ⇒ Object
44
45
46
|
# File 'lib/emit.rb', line 44
def process(*args, **kwargs, &block)
Process.new(*args, **kwargs, &block)
end
|
.retire(*channel_ends) ⇒ Object
52
53
54
|
# File 'lib/emit.rb', line 52
def retire(*channel_ends)
channel_ends.each(&:retire)
end
|
.sequence(*processes) ⇒ Object
36
37
38
|
# File 'lib/emit.rb', line 36
def sequence(*processes)
processes.flatten.each(&:run)
end
|