class StraightServer::Thread

Constants

INTERRUPTION_FLAG

Public Class Methods

interrupt(label:) click to toggle source
# File lib/straight-server/thread.rb, line 12
def self.interrupt(label:)
  redis = StraightServer.redis_connection
  redis.set INTERRUPTION_FLAG[label], Time.now.to_i
end
interrupted?(thread:) click to toggle source
# File lib/straight-server/thread.rb, line 17
def self.interrupted?(thread:)
  redis  = StraightServer.redis_connection
  result = redis.get(key = INTERRUPTION_FLAG[thread[:label]])
  redis.del key if result
  !!result
end
new(label: nil, &block) click to toggle source
# File lib/straight-server/thread.rb, line 4
def self.new(label: nil, &block)
  thread         = ::Thread.new(&block)
  thread[:label] = label
  thread
end