Oh you had not fixed it in your code too...
Got it, thanks,
Best regards,
Ozgur (Oscar) Ozturk
www.DrOzgur.com
+1 (614) 805-4370
On Sat, Jul 11, 2009 at 6:43 PM, Zachary Turner
On Sat, Jul 11, 2009 at 5:35 PM, Ozgur Ozturk
wrote: Hi, Thanks Zachary, yes, I have made a typo, thanks for pointing to it, and for the explanation. But it I have the same question for your code since we have a similar (interleaved) output. What I understood was, when we call io.run, main thread is suspended until things assigned to it finishes. (that is why in the examples the final count is not printed before an io.run() completes, right?!) so how come io2.run() is invoked from main thread (before io.run() finishes) (and we can get interleaved results)? Something I must be getting wrong.
The typo is what's causing the interleaved results :) io2 is never being used. timer2 is attached simply to io. So you have 2 timers both using the same io_service. If I change the code so that timer2 uses io2, I get the following output:
[start]: t1exp: 00:00:00.984375, t2exp: 00:00:01 1: timer1, t1exp: 00:00:02.984375, t2exp: 00:00:01 2: timer1, t1exp: 00:00:01, t2exp: -00:00:01.984375 3: timer1, t1exp: 00:00:01, t2exp: -00:00:02.984375 4: timer1, t1exp: 00:00:01, t2exp: -00:00:03.984375 5: timer1, t1exp: 00:00:01, t2exp: -00:00:04.984375 Final count is 5
In this case, it will actually call print with timer2 at the very end, but by then count is already 5, so it does not enter the if statement and just returns immediately. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users