Skip to content

Commit

Permalink
remove localize_vars from @schedule. ref JuliaLang#8591
Browse files Browse the repository at this point in the history
There really needs to be some macro that does this kind of thing without
playing games with your variables.
  • Loading branch information
JeffBezanson committed Oct 8, 2014
1 parent 41e5484 commit aa9f699
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
28 changes: 17 additions & 11 deletions base/multi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ function accept_handler(server::TCPServer, status::Int32)
end

function create_message_handler_loop(sock::AsyncStream; ntfy_join_complete=nothing) #returns immediately
schedule(@task begin
@schedule begin
global PGRP
#println("message_handler_loop")
disable_nagle(sock)
Expand All @@ -823,26 +823,32 @@ function create_message_handler_loop(sock::AsyncStream; ntfy_join_complete=nothi
id = deserialize(sock)
f = deserialize(sock)
args = deserialize(sock)
@schedule begin
v = run_work_thunk(()->f(args...))
deliver_result(sock, msg, id, v)
v
let f=f, args=args, id=id, msg=msg
@schedule begin
v = run_work_thunk(()->f(args...))
deliver_result(sock, msg, id, v)
v
end
end
elseif is(msg, :call_wait)
id = deserialize(sock)
notify_id = deserialize(sock)
f = deserialize(sock)
args = deserialize(sock)
@schedule begin
rv = schedule_call(id, ()->f(args...))
deliver_result(sock, msg, notify_id, wait_full(rv))
let f=f, args=args, id=id, msg=msg, notify_id=notify_id
@schedule begin
rv = schedule_call(id, ()->f(args...))
deliver_result(sock, msg, notify_id, wait_full(rv))
end
end
elseif is(msg, :do)
f = deserialize(sock)
args = deserialize(sock)
#print("got args: $args\n")
@schedule begin
run_work_thunk(RemoteValue(), ()->f(args...))
let f=f, args=args
@schedule begin
run_work_thunk(RemoteValue(), ()->f(args...))
end
end
elseif is(msg, :result)
# used to deliver result of wait or fetch
Expand Down Expand Up @@ -924,7 +930,7 @@ function create_message_handler_loop(sock::AsyncStream; ntfy_join_complete=nothi

return nothing
end
end)
end
end

function disable_threaded_libs()
Expand Down
2 changes: 1 addition & 1 deletion base/task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ end

# schedule an expression to run asynchronously, with minimal ceremony
macro schedule(expr)
expr = localize_vars(:(()->($expr)), false)
expr = :(()->($expr))
:(enq_work(Task($(esc(expr)))))
end

Expand Down

0 comments on commit aa9f699

Please sign in to comment.