| Thread overview | |||||||
|---|---|---|---|---|---|---|---|
|
February 04, 2015 Concurrent Thread Safe List? | ||||
|---|---|---|---|---|
| ||||
I'm looking for a non-blocking way of a thread pushing objects into a list and another thread able to pull objects from the same list. Thread 1 pushes objects onto the list, Thread 2 pulls the oldest objects off the list. Does D language have something like that? | ||||
February 04, 2015 Re: Concurrent Thread Safe List? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Gan | On 02/04/2015 12:10 PM, Gan wrote: > I'm looking for a non-blocking way of a thread pushing objects into a > list and another thread able to pull objects from the same list. Thread > 1 pushes objects onto the list, Thread 2 pulls the oldest objects off > the list. > > Does D language have something like that? The std.concurrency module does exactly that: http://dlang.org/phobos/std_concurrency.html And something I wrote: http://ddili.org/ders/d.en/concurrency.html Ali | |||
February 05, 2015 Re: Concurrent Thread Safe List? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Wednesday, 4 February 2015 at 22:14:31 UTC, Ali Çehreli wrote:
> On 02/04/2015 12:10 PM, Gan wrote:
>> I'm looking for a non-blocking way of a thread pushing objects into a
>> list and another thread able to pull objects from the same list. Thread
>> 1 pushes objects onto the list, Thread 2 pulls the oldest objects off
>> the list.
>>
>> Does D language have something like that?
>
> The std.concurrency module does exactly that:
>
> http://dlang.org/phobos/std_concurrency.html
>
> And something I wrote:
>
> http://ddili.org/ders/d.en/concurrency.html
>
> Ali
Cool article. First half of the article I was thinking, this isn't what I want. Then in the second half where you got into the mailbox analogy, that's exactly what I want.
Thanks.
| |||
February 05, 2015 Re: Concurrent Thread Safe List? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Gan | On Thursday, 5 February 2015 at 02:13:23 UTC, Gan wrote:
> On Wednesday, 4 February 2015 at 22:14:31 UTC, Ali Çehreli wrote:
>> On 02/04/2015 12:10 PM, Gan wrote:
>>> I'm looking for a non-blocking way of a thread pushing objects into a
>>> list and another thread able to pull objects from the same list. Thread
>>> 1 pushes objects onto the list, Thread 2 pulls the oldest objects off
>>> the list.
>>>
>>> Does D language have something like that?
>>
>> The std.concurrency module does exactly that:
>>
>> http://dlang.org/phobos/std_concurrency.html
>>
>> And something I wrote:
>>
>> http://ddili.org/ders/d.en/concurrency.html
>>
>> Ali
>
> Cool article. First half of the article I was thinking, this isn't what I want. Then in the second half where you got into the mailbox analogy, that's exactly what I want.
>
> Thanks.
If I want a non blocking receive call, would I do bool receiveTimeout(T...)(Duration duration, T ops); with a duration of 0?
| |||
February 05, 2015 Re: Concurrent Thread Safe List? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Gan | On 02/04/2015 06:33 PM, Gan wrote: > If I want a non blocking receive call, would I do bool > receiveTimeout(T...)(Duration duration, T ops); with a duration of 0? Yes but I am not sure whether the thread simply checks whether there is a message or also sleeps for 0 msecs. Ali | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply