Permalink
Browse files

If the invocation receives inbound data before it is started, it shou…

…ld delay passing it on to its callback until after it is started.
  • Loading branch information...
1 parent 152a137 commit dfc9d7b67133afd8dea91be03a0d9dcca6d4e7d7 Samuel Tesla committed May 26, 2009
Showing with 12 additions and 2 deletions.
  1. +12 −2 lib/pelvis/invocation.rb
View
@@ -12,6 +12,7 @@ def initialize(incall, actor_klass, operation)
attr_reader :incall, :actor_klass, :operation, :actor
def start
+ @started_at = Time.now
logger.debug "starting invocation: #{@actor_klass.inspect}, #{@operation.inspect}"
actor = @actor_klass.start(self, @operation)
actor.on_received do |data|
@@ -31,6 +32,10 @@ def start
end
end
+ def started?
+ @started_at
+ end
+
def agent
@incall.agent
end
@@ -52,8 +57,13 @@ def finished?
end
def put(data)
- logger.debug "invocation put: #{data.inspect}"
- sent(data)
+ t = EM::PeriodicTimer.new(0.015) do
+ if started?
+ logger.debug "invocation put: #{data.inspect}"
+ sent(data)
+ t.cancel
+ end
+ end
end
end
end

0 comments on commit dfc9d7b

Please sign in to comment.