/usr/lib/ruby/vendor_ruby/celluloid/tasks/task_fiber.rb is in ruby-celluloid 0.16.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | module Celluloid
class FiberStackError < Celluloid::Error; end
# Tasks with a Fiber backend
class TaskFiber < Task
def create
queue = Thread.current[:celluloid_queue]
actor_system = Thread.current[:celluloid_actor_system]
@fiber = Fiber.new do
# FIXME: cannot use the writer as specs run inside normal Threads
Thread.current[:celluloid_role] = :actor
Thread.current[:celluloid_queue] = queue
Thread.current[:celluloid_actor_system] = actor_system
yield
end
end
def signal
Fiber.yield
end
# Resume a suspended task, giving it a value to return if needed
def deliver(value)
@fiber.resume value
rescue SystemStackError => ex
raise FiberStackError, "#{ex} (please see https://github.com/celluloid/celluloid/wiki/Fiber-stack-errors)"
rescue FiberError => ex
raise DeadTaskError, "cannot resume a dead task (#{ex})"
end
# Terminate this task
def terminate
super
rescue FiberError
# If we're getting this the task should already be dead
end
def backtrace
["#{self.class} backtrace unavailable. Please try `Celluloid.task_class = Celluloid::TaskThread` if you need backtraces here."]
end
end
end
|