Skip to content
Browse files

make ruby eval lambda non-blocking. fix memory leak

  • Loading branch information...
1 parent 8b9bcb9 commit 787612045d32be0ef237a21008213fbb7d23895b @ninjudd ninjudd committed Aug 1, 2011
Showing with 5 additions and 12 deletions.
  1. +5 −12 client/ruby/portal.rb
View
17 client/ruby/portal.rb
@@ -50,7 +50,7 @@ def receive_message
def context(id)
@contexts[id.to_s] ||= {
- :results => [],
+ :results => {},
:count => 0,
:stdout => IO.pipe,
:stderr => IO.pipe
@@ -69,17 +69,10 @@ def eval(form, id = @id || rand)
context = context(id)
count = context[:count] += 1;
lambda do
- while (count > context[:results].size)
- sleep(RESULT_WAIT)
- end
- type, form = context[:results][count - 1]
- if type == "result"
- form.split("\n")
- else
- vals = form.split("\n")
- vals[-1] = {type.to_sym => vals[-1]}
- vals
- end
+ return unless type
+ vals = form.split("\n")
+ vals[-1] = {type.to_sym => vals[-1]} unless type == "result"
+ vals
end
end

0 comments on commit 7876120

Please sign in to comment.
Something went wrong with that request. Please try again.