mirror of
https://github.com/hkalexling/Mango.git
synced 2026-05-01 00:00:55 -04:00
Fix CLI tool not exiting
This commit is contained in:
+8
-3
@@ -6,6 +6,7 @@
|
||||
class MainFiber
|
||||
@@channel = Channel(-> Nil).new
|
||||
@@done = Channel(Bool).new
|
||||
@@main_fiber = Fiber.current
|
||||
|
||||
def self.start_and_block
|
||||
loop do
|
||||
@@ -21,9 +22,13 @@ class MainFiber
|
||||
end
|
||||
|
||||
def self.run(&block : -> Nil)
|
||||
@@channel.send block
|
||||
until @@done.receive
|
||||
Fiber.yield
|
||||
if @@main_fiber == Fiber.current
|
||||
block.call
|
||||
else
|
||||
@@channel.send block
|
||||
until @@done.receive
|
||||
Fiber.yield
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user