Is there any threadsafe queue?
John Burton via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Sep 13 10:04:34 UTC 2017
On Wednesday, 13 September 2017 at 09:49:46 UTC, Jonathan M Davis
wrote:
> On Wednesday, September 13, 2017 07:51:19 John Burton via
> Digitalmars-d- learn wrote:
>> [...]
>
> You could probably do what you want with std.concurrency, since
> most of what it does is deal with sending and receiving data
> across threads, and that should be queuing up messages as part
> of what it does. But if you're looking for a data structure
> that you can mark as shared and have it handle all of the
> locking for you so that it will work safely across threads,
> then no, the standard library does not currently have anything
> like that. It's rather lacking in containers in general at this
> point, let alone ones designed with concurrency in mind. There
> may be something on code.dlang.org, but I don't know.
> Regardless, I'd suggest that you first try and see if you can
> get std.concurrency to work for your use case rather than
> jumping into implementing any containers yourself.
Thanks, I took a better look. I was wanting to port some c++ code
which is why I was looking for this. Actually it looks like
"send" and "receive" functions from this package do exactly what
I need (and are in fact exactly a thread safe queue...) :)
More information about the Digitalmars-d-learn
mailing list