comparison: src/Comms.jl
src/Comms.jl
- changeset 6
- a5c1eb932d19
- parent 5
- 015025cf2a50
equal
deleted
inserted
replaced
| 9 ############## |
9 ############## |
| 10 # Our exports |
10 # Our exports |
| 11 ############## |
11 ############## |
| 12 |
12 |
| 13 export process_channel, |
13 export process_channel, |
| 14 put_onlylatest! |
14 put_onlylatest!, |
| |
15 put_unless_closed! |
| 15 |
16 |
| 16 #################### |
17 #################### |
| 17 # Channel iteration |
18 # Channel iteration |
| 18 #################### |
19 #################### |
| 19 |
20 |
| 29 break |
30 break |
| 30 end |
31 end |
| 31 try |
32 try |
| 32 fn(d) |
33 fn(d) |
| 33 catch ex |
34 catch ex |
| 34 error("Exception in process_channel handler. Terminating.\n$(ex)") |
35 error("Exception in process_channel handler. Terminating.\n") |
| 35 throw(ex) |
36 rethrow(ex) |
| 36 end |
37 end |
| 37 end |
38 end |
| 38 end |
39 end |
| 39 |
40 |
| 40 ############################################# |
41 ############################################# |
| 46 take!(rc) |
47 take!(rc) |
| 47 end |
48 end |
| 48 put!(rc, d) |
49 put!(rc, d) |
| 49 end |
50 end |
| 50 |
51 |
| |
52 ############################################ |
| |
53 # Cracefully return false if channel closed |
| |
54 ############################################ |
| |
55 |
| |
56 function put_unless_closed!(rc, d) |
| |
57 try |
| |
58 put!(rc, d) |
| |
59 catch ex |
| |
60 if isa(ex, InvalidStateException) && ex.state==:closed |
| |
61 return false |
| |
62 else |
| |
63 rethrow(ex) |
| |
64 end |
| |
65 end |
| |
66 return true |
| |
67 end |
| |
68 |
| 51 end # Module |
69 end # Module |
