Here is some code to highlight the question a bit:
class Game
property game_close = false
def initialize
spawn mob_ai
end
def mob_ai
loop do
break if game_close
puts "mob ai running"
sleep 1
end
end
end
games = Hash(String, Game).new
games["1"] = Game.new
sleep 0.5
games["1"].game_close = true
games.delete "1"
puts "Game 1 deleted"
sleep
Is doing break if game_close
the proper/correct way? I was thinking the fiber would be closed automatically, since it’s deleted from the games
hash (no references to it?). Am not entirely sure
Example, if you comment out games["1"].game_close = true
, the fiber’s loop will still be running