You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/async/container.rb
-1Lines changed: 0 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,6 @@
23
23
require_relative'container/controller'
24
24
25
25
moduleAsync
26
-
# Containers execute one or more "instances" which typically contain a reactor. A container spawns "instances" using threads and/or processes. Because these are resources that must be cleaned up some how (either by `join` or `waitpid`), their creation is deferred until the user invokes `Container#wait`. When executed this way, the container guarantees that all "instances" will be complete once `Container#wait` returns. Containers are constructs for achieving parallelism, and are not designed to be used directly for concurrency. Typically, you'd create one or more container, add some tasks to it, and then wait for it to complete.
Copy file name to clipboardExpand all lines: lib/async/container/best.rb
+9-3Lines changed: 9 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -25,12 +25,16 @@
25
25
require_relative'hybrid'
26
26
27
27
moduleAsync
28
-
# Containers execute one or more "instances" which typically contain a reactor. A container spawns "instances" using threads and/or processes. Because these are resources that must be cleaned up some how (either by `join` or `waitpid`), their creation is deferred until the user invokes `Container#wait`. When executed this way, the container guarantees that all "instances" will be complete once `Container#wait` returns. Containers are constructs for achieving parallelism, and are not designed to be used directly for concurrency. Typically, you'd create one or more container, add some tasks to it, and then wait for it to complete.
Copy file name to clipboardExpand all lines: lib/async/container/channel.rb
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -24,27 +24,40 @@
24
24
25
25
moduleAsync
26
26
moduleContainer
27
+
# Provides a basic multi-thread/multi-process uni-directional communication channel.
27
28
classChannel
29
+
# Initialize the channel using a pipe.
28
30
definitialize
29
31
@in,@out= ::IO.pipe
30
32
end
31
33
34
+
# The input end of the pipe.
35
+
# @attribute [IO]
32
36
attr:in
37
+
38
+
# The output end of the pipe.
39
+
# @attribute [IO]
33
40
attr:out
34
41
42
+
# Close the input end of the pipe.
35
43
defclose_read
36
44
@in.close
37
45
end
38
46
47
+
# Close the output end of the pipe.
39
48
defclose_write
40
49
@out.close
41
50
end
42
51
52
+
# Close both ends of the pipe.
43
53
defclose
44
54
close_read
45
55
close_write
46
56
end
47
57
58
+
# Receive an object from the pipe.
59
+
# Internally, prefers to receive newline formatted JSON, otherwise returns a hash table with a single key `:line` which contains the line of data that could not be parsed as JSON.
0 commit comments