Skip to content

Commit

Permalink
Merge pull request JuliaLang#15513 from JuliaLang/amitm/corrections
Browse files Browse the repository at this point in the history
minor corrections in WorkerPool and map iterators
  • Loading branch information
amitmurthy committed Mar 15, 2016
2 parents 24e0fdb + 685f440 commit 71c3d62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions base/mapiterator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ wait(state::AsyncMapState) = wait(state.task_done)

# Open a @sync block and initialise iterator state.
function start(itr::AsyncMapIterator)
Base.sync_begin()
sync_begin()
AsyncMapState(start(itr.arg_enum), 0, Condition(), false)
end

# Close @sync block when iterator is done.
function done(itr::AsyncMapIterator, state::AsyncMapState)
if !state.done && done(itr.arg_enum, state.enum_state)
state.done = true
Base.sync_end()
sync_end()
end
return state.done
end
Expand Down
7 changes: 5 additions & 2 deletions base/workerpool.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

type WorkerPool
channel::RemoteChannel{Channel{Int}}

# Create a shared queue of available workers...
WorkerPool() = new(RemoteChannel(()->Channel{Int}(typemax(Int))))
end


Expand All @@ -11,10 +14,10 @@ end
Create a WorkerPool from a vector of worker ids.
"""
function WorkerPool(workers=Int[])
function WorkerPool(workers::Vector{Int})

# Create a shared queue of available workers...
pool = WorkerPool(RemoteChannel(()->Channel{Int}(128)))
pool = WorkerPool()

# Add workers to the pool...
for w in workers
Expand Down

0 comments on commit 71c3d62

Please sign in to comment.