Sha256: a040d730838fec3d2a570eb93b7b6ea49bbe397486578ad9a367efb4d2d6a354

Contents?: true

Size: 1.01 KB

Versions: 15

Compression:

Stored size: 1.01 KB

Contents

require 'set'
require 'forwardable'

module Celluloid
  if defined? JRUBY_VERSION
    require 'jruby/synchronized'

    class TaskSet
      extend  Forwardable
      include JRuby::Synchronized

      def_delegators :@tasks, :<<, :delete, :first, :empty?, :to_a

      def initialize
        @tasks = Set.new
      end
    end
  elsif defined? Rubinius
    class TaskSet
      def initialize
        @tasks = Set.new
      end

      def <<(task)
        Rubinius.synchronize(self) { @tasks << task }
      end

      def delete(task)
        Rubinius.synchronize(self) { @tasks.delete task }
      end

      def first
        Rubinius.synchronize(self) { @tasks.first }
      end

      def empty?
        Rubinius.synchronize(self) { @tasks.empty? }
      end

      def to_a
        Rubinius.synchronize(self) { @tasks.to_a }
      end
    end
  else
    # Assume we're on MRI, where we have the GIL. But what about IronRuby?
    # Or MacRuby. Do people care? This will break Celluloid::StackDumps
    TaskSet = Set
  end
end

Version data entries

15 entries across 13 versions & 5 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/celluloid-0.16.0/lib/celluloid/task_set.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/celluloid-0.16.0/lib/celluloid/task_set.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/celluloid-0.16.0/lib/celluloid/task_set.rb
scoot-0.0.4 .bundle/gems/ruby/2.2.0/gems/celluloid-0.16.0/lib/celluloid/task_set.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/celluloid-0.16.0/lib/celluloid/task_set.rb
celluloid-0.16.0 lib/celluloid/task_set.rb
celluloid-0.16.0.pre3 lib/celluloid/task_set.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/celluloid-0.15.2/lib/celluloid/task_set.rb
celluloid-0.16.0.pre2 lib/celluloid/task_set.rb
celluloid-0.16.0.pre lib/celluloid/task_set.rb
celluloid-0.15.2 lib/celluloid/task_set.rb
celluloid-0.15.1 lib/celluloid/task_set.rb
celluloid-0.15.0 lib/celluloid/task_set.rb
celluloid-0.15.0.pre2 lib/celluloid/task_set.rb
celluloid-0.15.0.pre lib/celluloid/task_set.rb