Boost logo

Boost Users :

Subject: Re: [Boost-users] playing around with tutorial codes to understand ioservice
From: Ozgur Ozturk (ozgur7_at_[hidden])
Date: 2009-07-11 19:20:41


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 <divisortheory_at_[hidden]>wrote:

> On Sat, Jul 11, 2009 at 5:35 PM, Ozgur Ozturk<ozgur7_at_[hidden]> 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_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net