Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reboot: Update Select.jl for multithreaded, modern Julia #1

Merged
merged 22 commits into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
fcb7895
Fixed deprecations, working on fixing behavior
NHDaly Sep 3, 2019
03ba364
Update wait_put for new Channel implementation
NHDaly Sep 3, 2019
69c983f
Make `wait_put` thread-safe -- (I think?)
NHDaly Sep 3, 2019
5e620f3
Trying to fix scoping for channel and value vars -- maybe i only need…
NHDaly Sep 3, 2019
2a9eb90
Aha: found problem! Committing before trying to fix.
NHDaly Sep 3, 2019
50eaf0a
Fix threading-correctness && switch to at-spawn (instead of at-async)…
NHDaly Sep 3, 2019
69c0a8e
BUG: Reenable the `at-info`s I was using for debugging to show uv mul…
NHDaly Sep 3, 2019
da926e2
Revert "BUG: Reenable the `at-info`s I was using for debugging to sho…
NHDaly Sep 3, 2019
52098cb
Fix to also work with Tasks, not just Channels
NHDaly Sep 3, 2019
a4e853d
Fixed coordination b/w unrelated Cases: add synchronization on "case_…
NHDaly Sep 3, 2019
eecb153
Fixed put again. Tried to fix the circular reference problem, but failed
NHDaly Sep 3, 2019
2e81219
Undoing the extra loop, which didn't actually help anything
NHDaly Sep 3, 2019
1e55025
Switch to multithreading the separate tasks in Select
NHDaly Sep 3, 2019
de1ba80
Fix remaining tests: Fix fetching from Tasks, fix non-blocking select…
NHDaly Sep 4, 2019
3a7ad5a
Reorder tests
NHDaly Sep 4, 2019
b0a23af
Add Project.toml
NHDaly Sep 4, 2019
df47c3b
Update .travis.yml for Julia 1.3+ and multithreading
NHDaly Sep 4, 2019
7e74c95
Update README to reflect that this is an updated copy of durcan/Selec…
NHDaly Sep 4, 2019
e4a27cb
Reroganized test files into testsets
NHDaly Sep 4, 2019
ada041b
Oops: fix typo in isready_put: `in`, not `occursin`
NHDaly Sep 4, 2019
7a8900f
Add example programs from Golang's intro to Select statements
NHDaly Sep 4, 2019
0a167bf
Add test for select-blocking which is already ready
NHDaly Sep 4, 2019
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
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ os:
- linux
- osx
julia:
- release
- 1.3
- nightly
env:
- JULIA_NUM_THREADS=1
- JULIA_NUM_THREADS=6


notifications:
email: false
# uncomment the following lines to override the default test script
Expand Down
17 changes: 17 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name = "Select"
uuid = "ac7b3b08-bf78-4e82-aa6e-b038cb67d740"
authors = ["Nathan Daly <[email protected]>", "Brett Cornell <[email protected]>",
"Jon Malmaud <[email protected]>"]
version = "0.1.0"

[deps]
Nullables = "4d1e1d77-625e-5b40-9113-a560ec7a8ecd"

[compat]
julia = "1.3"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# Select

This is copy of [Jon Malmaud's](https://github.com/malmaud) go inspired select macro for the Julia programming language. I have made a slight syntax modification, but essentially all the code is his.

This packege is currently not registered and can be installed with:
This repo is branched from https://github.com/durcan/Select.jl, which was originally a copy of [Jon Malmaud's](https://github.com/malmaud) go-inspired select macro for the Julia programming language. I have updated the repo for Julia 1.3+, multithreaded the Select macro, and hardened the code a bit.

Install this package via:
```julia
julia> Pkg.add("https://github.com/NHDaly/Select.jl")
```
Pkg.clone("https://github.com/durcan/Select.jl.git")
```

The original README from [durcan/Select.jl](https://github.com/durcan/Select.jl) follows:

-----------------------------------------------------

This is copy of [Jon Malmaud's](https://github.com/malmaud) go inspired select macro for the Julia programming language. I have made a slight syntax modification, but essentially all the code is his.


A select expression is for waiting on multiple communication operations and is of the form:
Expand Down
35 changes: 35 additions & 0 deletions examples/default.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module Default
using Select

doevery(secs) = Channel{Int}() do ch
while true
sleep(secs)
put!(ch, 1)
end
end
doafter(secs) = Channel{Int}() do ch
sleep(secs)
put!(ch, 1)
end

function main()
tick = doevery(0.1)
boom = doafter(0.5)
while true
@select begin
tick => println("tick.")
boom => begin
println("BOOM!")
return
end
_ => begin
println(" .")
sleep(0.05)
end
end
end
end

main()

end
38 changes: 38 additions & 0 deletions examples/fibonacci.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translated from the Golang Tour's select intro: https://tour.golang.org/concurrency/5
module Fibonacci

using Select
import Base.Threads: @spawn

function fibonacci(c::Channel{>:Int}, quit::Channel{>:Int})
x, y = 0, 1
while true
@select begin
c <| x => begin
x, y = y, x+y
end
quit => begin
println("quit")
return
end
end
end
end

function main()
@sync begin
c = Channel{Int}()
quit = Channel{Int}()
@spawn begin
for i in 0:9
println(take!(c))
end
put!(quit, 0)
end
fibonacci(c, quit)
end
end

main()

end
Loading