iconara / mikka

JRuby wrapper for Akka
107 stars 14 forks source link

Scheduling #4

Closed gaiottino closed 12 years ago

gaiottino commented 12 years ago

I've added scheduling to Mikka. I chose to add helper methods to Mikka instead of wrapping Scheduler as akka.actor.Scheduler is a final class.

iconara commented 12 years ago

I'd like the scheduling methods to be in a module, that way you can mix them into an actor, for example:

module Mikka
  module Scheduling
    extend self

    def schedule(...)
    end
  end
end

class Stallone < Mikka::Actor
  include Mikka::Scheduling

  def pre_start
    schedule(...)
  end
end

I've changed the Remote and Messages modules to work this way too. Doing it this way would also make it possible to get back to the way you've done it in your own app, by doing

module Mikka
  extend Mikka::Scheduling
end

I also think that it should be possible to pass :seconds, :minutes, etc. as the time unit parameter (in addition to the TimeUnit::XYZ constants).