April 27, 2012 Re: [D-runtime] What's with core.sync.condition usage? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steve Schveighoffer Attachments:
| One of Bartosz' videos is on condition variables. Also, if it helps, Java has wait and notify calls built into Object that work exactly the same way.
On Apr 27, 2012, at 3:21 AM, Steve Schveighoffer <schveiguy@yahoo.com> wrote:
> Just like Sean said. It's just his comment that puzzled me.
>
> Examples would be nice. I've done an article in the past on thread programming, maybe I'll do something for this. If you search google for mutex condition, I'm sure you'll find loads of examples.
>
> -Steve
>
> From: Alex Rønne Petersen <xtzgzorex@gmail.com>
> To: D's runtime library developers list <d-runtime@puremagic.com>
> Sent: Thursday, April 26, 2012 7:10 PM
> Subject: Re: [D-runtime] What's with core.sync.condition usage?
>
> Now I'm really confused.
>
> How is this thing *actually* supposed to be used? And can we add some examples to the docs?
>
> Regards,
> Alex
>
> On Fri, Apr 27, 2012 at 1:08 AM, Sean Kelly <sean@invisibleduck.org> wrote: On Apr 26, 2012, at 1:22 PM, Steve Schveighoffer wrote:
> >
> > From: Sean Kelly <sean@invisibleduck.org>
> > void put(T val) {
> > synchronized (cond.mutex) {
> > queue.pushBack(val);
> > cond.notify(); // atomically unlocks mutex on call, locks on return
> > }
> > }
> > Huh, I thought notify did not unlock the mutex at all (I don't see why it would need to).
>
> Oops… you're right. The original implementation (Hoare's) did, I believe, but the modern one does not.
> _______________________________________________
> D-runtime mailing list
> D-runtime@puremagic.com
> http://lists.puremagic.com/mailman/listinfo/d-runtime
>
>
> _______________________________________________
> D-runtime mailing list
> D-runtime@puremagic.com
> http://lists.puremagic.com/mailman/listinfo/d-runtime
>
>
> _______________________________________________
> D-runtime mailing list
> D-runtime@puremagic.com
> http://lists.puremagic.com/mailman/listinfo/d-runtime
|
Copyright © 1999-2021 by the D Language Foundation