Sha256: 8bf5307f49bc16b59a835da1e1a7cf869c89c69d8935ccbe8c35e293c76186a7

Contents?: true

Size: 547 Bytes

Versions: 20

Compression:

Stored size: 547 Bytes

Contents

# Event lock. Locks current thread until matching event is emitted
# @!attribute [r] plug
#  @return [Plug] Plug
# @!attribute [r] pattern
#  @return [Hash<Symbol>] Pattern
class ProtonBot::EventLock
  attr_reader :plug, :pattern

  # @param plug [Plug]
  # @param pattern [Hash<Symbol>]
  def initialize(plug, pattern)
    @plug = plug
    @plug.event_locks << self
    @pattern = pattern
    @unlock = false
    sleep(0.01) until @unlock
  end

  # Unlocks current thread
  # @return [NilClass]
  def unlock
    @unlock = true
    nil
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
protonbot-0.3.7 lib/protonbot/event_lock.rb
protonbot-0.3.6 lib/protonbot/event_lock.rb
protonbot-0.3.5 lib/protonbot/event_lock.rb
protonbot-0.3.4 lib/protonbot/event_lock.rb
protonbot-0.3.3 lib/protonbot/event_lock.rb
protonbot-0.3.2 lib/protonbot/event_lock.rb
protonbot-0.3.1 lib/protonbot/event_lock.rb
protonbot-0.3.0 lib/protonbot/event_lock.rb
protonbot-0.2.7 lib/protonbot/event_lock.rb
protonbot-0.2.6 lib/protonbot/event_lock.rb
protonbot-0.2.5 lib/protonbot/event_lock.rb
protonbot-0.2.4 lib/protonbot/event_lock.rb
protonbot-0.2.3 lib/protonbot/event_lock.rb
protonbot-0.2.2 lib/protonbot/event_lock.rb
protonbot-0.2.1 lib/protonbot/event_lock.rb
protonbot-0.2.0 lib/protonbot/event_lock.rb
protonbot-0.1.3 lib/protonbot/event_lock.rb
protonbot-0.1.2 lib/protonbot/event_lock.rb
protonbot-0.1.1 lib/protonbot/event_lock.rb
protonbot-0.1.0 lib/protonbot/event_lock.rb