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