Method: Celluloid::Task::Threaded#create

Defined in:
lib/celluloid/task/threaded.rb

#createObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/celluloid/task/threaded.rb', line 16

def create
  # TODO: move this to ActorSystem#get_thread (ThreadHandle inside Group::Pool)
  thread = Internals::ThreadHandle.new(Thread.current[:celluloid_actor_system], :task) do
    begin
      ex = @resume_queue.pop
      fail ex if ex.is_a?(TaskTerminated)

      yield
    rescue ::Exception => ex
      @exception_queue << ex
    ensure
      @yield_mutex.synchronize do
        @yield_cond.signal
      end
    end
  end
  @thread = thread
end