Skip to content

Commit

Permalink
add n_avail/capacity(RemoteRef{Channel})
Browse files Browse the repository at this point in the history
  • Loading branch information
alyst committed Aug 24, 2015
1 parent a487ddb commit 7e846e3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions base/multi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -514,15 +514,6 @@ function lookup_ref(pg, id, f)
rv
end

function isready(rr::RemoteRef, args...)
rid = rr2id(rr)
if rr.where == myid()
isready(lookup_ref(rid).c, args...)
else
remotecall_fetch(rr.where, id->isready(lookup_ref(rid).c, args...), rid)
end
end

del_client(id, client) = del_client(PGRP, id, client)
function del_client(pg, id, client)
rv = lookup_ref(id)
Expand Down Expand Up @@ -774,6 +765,15 @@ function call_on_owner(f, rr::RemoteRef, args...)
end
end

for f in (:isready, :n_avail, :capacity)
f_ref = symbol(string(f, "_ref"))
@eval begin
($f)(rv::RemoteValue, args...) = ($f)(rv.c, args...)
($f_ref)(rid, args...) = ($f)(lookup_ref(rid).c, args...)
($f)(rr::RemoteRef, args...) = call_on_owner(($f_ref), rr, args...)
end
end

wait_ref(rid, args...) = (wait(lookup_ref(rid).c, args...); nothing)
wait(r::RemoteRef, args...) = (call_on_owner(wait_ref, r, args...); r)

Expand Down

0 comments on commit 7e846e3

Please sign in to comment.