I have been pulling my hair out for weeks on this niggling problem, and I just can\'t find any info or tips on how or what to do, so I\'m hoping someone here on the RubyMoti
Here's what I do to make multi-threaded synchronized asynchronous calls.
def make_sync2(&block)
@semaphore ||= Dispatch::Semaphore.new(0)
@semaphore2 ||= Dispatch::Semaphore.new(1)
BubbleWrap::Reactor.schedule do
result = block.call("Mateus")
@semaphore2.wait # Wait for access to @result
@result = result
@semaphore.signal
end
@semaphore.wait # Wait for async task to complete
result = @result
@semaphore2.signal
result
end