Sha256: 4a3f44fde81d098e622ed57e1c3af0d573e1c617a74d7776edcc6579211a1f16

Contents?: true

Size: 650 Bytes

Versions: 9

Compression:

Stored size: 650 Bytes

Contents

module Celluloid
  module Internals
    # Event signaling between methods of the same object
    class Signals
      def initialize
        @conditions = {}
      end

      # Wait for the given signal and return the associated value
      def wait(name)
        fail "cannot wait for signals while exclusive" if Celluloid.exclusive?

        @conditions[name] ||= Condition.new
        @conditions[name].wait
      end

      # Send a signal to all method calls waiting for the given name
      def broadcast(name, value = nil)
        condition = @conditions.delete(name)
        condition.broadcast(value) if condition
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
celluloid-essentials-0.20.5 lib/celluloid/internals/signals.rb
celluloid-essentials-0.20.2.1 lib/celluloid/internals/signals.rb
celluloid-essentials-0.20.2 lib/celluloid/internals/signals.rb
celluloid-essentials-0.20.1.1 lib/celluloid/internals/signals.rb
celluloid-essentials-0.20.1 lib/celluloid/internals/signals.rb
celluloid-essentials-0.20.0 lib/celluloid/internals/signals.rb
celluloid-essentials-0.20.0.pre17 lib/celluloid/internals/signals.rb
celluloid-essentials-0.20.0.pre16 lib/celluloid/internals/signals.rb
celluloid-essentials-0.20.0.pre15 lib/celluloid/internals/signals.rb