PierreW
2010-Jun-02 16:39 UTC
Multiple threads writing to the same Starling queue doesn''t work?
Hi guys,
I can''t find a clear answer to this: is it possible/correct to have
several threads write to the same Starling queue at the "same time"?
It doesn''t seem reliable according to my tests - but maybe I am doing
something wrong.
If I do:
def test_starling
FooWorker.asynch_foo_test(:my_id => ''foo'')
temp = []
for i in 1..1000
temp << Thread.new(i) {|random_value| do_stuff(random_value)}
end
temp.each do |t|
t.join
end
end
def do_stuff(lvalue)
starling = Starling.new(''localhost:22122'')
starling.set(''foo'', :rvalue => lvalue)
end
# In FooWorker:
def foo_test(options)
starling = Starling.new(''localhost:22122'')
while true
temp = starling.get(options[: my_id].to_s)
puts temp.inspect
end
end
Some of the queue values don''t get output to the console (randomly).
I could get it to work with a mutex but it doesn''t seem right to me -
there should be a way to do that without having to lock the queue?
Thanks,
Pierre
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
