Ticket #95 (closed enhancement: fixed)

Opened 1 year ago

Last modified 1 year ago

EM.schedule helper for threaded environments

Reported by: raggi Assigned to: raggi
Priority: major Milestone: EventMachine "Framework"
Keywords: Cc:

Description

def EventMachine.run(*args)
  Thread.current[:eventmachine_main] = true
  super
end

def EventMachine.schedule(&job)
  if Thread.current[:eventmachine_main]
    job.call
  else
    next_tick &job
  end
end

Motivation - always kick stuff onto the EM thread, to avoid thread safety issues. We don't want locks because locks are slow.

Change History

03/26/09 20:09:02 changed by raggi

  • status changed from new to closed.
  • resolution set to fixed.