Sha256: 30046f1ed345a708d60ce4c6cb72aeb4d894240a07d2b3886ade2de086ee3d61
Contents?: true
Size: 533 Bytes
Versions: 20
Compression:
Stored size: 533 Bytes
Contents
# n秒間sleepしつつ、mainスレッドをm秒間隔で動かしたい時に使う class ProconBypassMan::CycleSleep attr_accessor :cycle_interval, :execution_cycle def initialize(cycle_interval: , execution_cycle: ) @cycle_interval = cycle_interval @execution_cycle = execution_cycle @counter = 0 end def sleep_or_execute result = nil if @counter >= @execution_cycle @counter = 0 result = yield else @counter += 1 end sleep(@cycle_interval) return result end end
Version data entries
20 entries across 20 versions & 1 rubygems