-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.rb
63 lines (59 loc) · 1.02 KB
/
test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require 'redis'
50.times do
8.times.map do
Thread.new do
25.times do |i|
redis = Redis.new(host: "0.0.0.0", port: 9009)
redis.set(i, i)
redis.get(i)
sleep 0.01
redis.close
end
end
end.each(&:join)
end
#
# pipe1 = Ractor.new do
# loop do
# msg = Ractor.receive
# puts "pipe1 received: #{msg}"
# Ractor.yield(msg, move: true)
# end
# end
#
# pipe2 = Ractor.new do
# loop do
# msg = Ractor.receive
# puts "pipe2 received: #{msg}"
# Ractor.yield(msg, move: true)
# end
# end
#
# Ractor.new(pipe1, pipe2) do |pipe1, pipe2|
# Thread.new do
# loop do
# msg = pipe1.take
# puts "thread1 [pipe1]: #{msg}"
# end
# end
#
# Thread.new do
# loop do
# msg = pipe2.take
# puts "thread2 [pipe2]: #{msg}"
# end
# end
#
# sleep
# end
#
# 3.times do |i|
# Thread.new do
# pipe1.send("#{i} was sent to pipe1")
# # end
# # Thread.new do
# pipe2.send("#{i} was sent to pipe2")
# end
# end
#
# sleep