File: stack_methods.rb

package info (click to toggle)
ruby-celluloid 0.18.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 848 kB
  • sloc: ruby: 7,579; makefile: 10
file content (23 lines) | stat: -rw-r--r-- 514 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def create_async_blocking_actor(task_klass)
  actor_klass = Class.new(StackBlocker) do
    task_class task_klass
  end

  actor = actor_system.within do
    actor_klass.new(threads)
  end

  actor.async.blocking
end

def create_thread_with_role(threads, role)
  resume = Queue.new
  thread = actor_system.get_thread do
    resume.pop # to avoid race for 'thread' variable
    thread.role = role
    threads << thread
    StackWaiter.forever
  end
  resume << nil # to avoid race for 'thread' variable
  thread
end