Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/src/_changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ This documents notable changes in DistributedNext.jl. The format is based on

## Unreleased

### Fixed
- Fixed behaviour of `isempty(::RemoteChannel)`, which previously had the
side-effect of taking an element from the channel ([#3]).

### Changed
- Added a `project` argument to [`addprocs(::AbstractVector)`](@ref) to specify
the project of a remote worker ([#2]).
3 changes: 3 additions & 0 deletions src/remotecall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,9 @@ close(rr::RemoteChannel) = call_on_owner(close_ref, rr)
isopen_ref(rid) = isopen(lookup_ref(rid).c)
isopen(rr::RemoteChannel) = call_on_owner(isopen_ref, rr)

isempty_ref(rid) = isempty(lookup_ref(rid).c)
Base.isempty(rr::RemoteChannel) = call_on_owner(isempty_ref, rr)

getindex(r::RemoteChannel) = fetch(r)
getindex(r::Future) = fetch(r)

Expand Down
12 changes: 12 additions & 0 deletions test/distributed_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,18 @@ let ch = RemoteChannel(() -> Channel(1))
@test 10 == test_iteration_collect(ch)
end

# Test isempty(::RemoteChannel). This should not modify the underlying
# AbstractChannel, which Base's default implementation will do.
let
chan = Channel(1)
push!(chan, 1)
remotechan = RemoteChannel(() -> chan)

@test !isempty(remotechan)
# Calling `isempty(remotechan)` shouldn't have modified `chan`
@test !isempty(chan)
end

# make sure exceptions propagate when waiting on Tasks
@test_throws CompositeException (@sync (@async error("oops")))
try
Expand Down