Skip to content

Commit

Permalink
make ruby eval lambda non-blocking. fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjudd committed Aug 2, 2011
1 parent 8b9bcb9 commit 7876120
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions client/ruby/portal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def receive_message

def context(id)
@contexts[id.to_s] ||= {
:results => [],
:results => {},
:count => 0,
:stdout => IO.pipe,
:stderr => IO.pipe
Expand All @@ -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

Expand Down

0 comments on commit 7876120

Please sign in to comment.