Module: Kernel

Defined in:
lib/kernel/sync.rb,
lib/kernel/async.rb

Instance Method Summary collapse

Instance Method Details

#Async(*arguments, **options, &block) ⇒ Object

Run the given block of code in a task, asynchronously, creating a reactor if necessary.



27
28
29
# File 'lib/kernel/async.rb', line 27

def Async(*arguments, **options, &block)
	::Async::Reactor.run(*arguments, **options, &block)
end

#Sync(&block) ⇒ Object

Run the given block of code synchronously, but within a reactor if not already in one.



27
28
29
30
31
32
33
# File 'lib/kernel/sync.rb', line 27

def Sync(&block)
	if task = ::Async::Task.current?
		yield task
	else
		::Async::Reactor.run(&block).wait
	end
end