www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Is there a thread safe single linked list?

reply "denizzzka" <4denizzz gmail.com> writes:
Hi!

Specifically, pushBack(x) and moveFront() operations should be a 
thread safe.
Oct 12 2012
next sibling parent "denizzzka" <4denizzz gmail.com> writes:
or dynamic array with this methods
Oct 12 2012
prev sibling parent reply "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Friday, October 12, 2012 14:59:56 denizzzka wrote:
 Hi!
 
 Specifically, pushBack(x) and moveFront() operations should be a
 thread safe.
Not in Phobos. No containers in Phobos contain any kind of synchronization. The same goes for the built-in array types. If any of them are shared, you'll need to protect them appropriately. If any kind of thread-safe container exists, it's in a third party library somewhere. - Jonathan M Davis
Oct 12 2012
parent reply "denizzzka" <4denizzz gmail.com> writes:
Thanks for answer!

After investigation came to the conclusion that here is needed 
not synchronized-based solution. I am need compare-and-swap 
single linked list because it will be used in callback proc from 
C, and it cannot be throwable, but synchronized contains 
throwable _d_monitorenter and_d_monitorexit.

I would be grateful if someone share singly linked list based on 
cas()
Oct 12 2012
next sibling parent "denizzzka" <4denizzz gmail.com> writes:
 I would be grateful if someone share singly linked list based 
 on cas()
Ok, this is a good opportunity to learn how to write such by oneself :-)
Oct 12 2012
prev sibling parent reply Sean Kelly <sean invisibleduck.org> writes:
On Oct 12, 2012, at 10:18 AM, denizzzka <4denizzz gmail.com> wrote:

 Thanks for answer!
=20
 After investigation came to the conclusion that here is needed not =
synchronized-based solution. I am need compare-and-swap single linked = list because it will be used in callback proc from C, and it cannot be = throwable, but synchronized contains throwable _d_monitorenter = and_d_monitorexit.
=20
 I would be grateful if someone share singly linked list based on cas()
There's a sample Stack and SList implementation in the concurrency = chapter: http://www.informit.com/articles/printerfriendly.aspx?p=3D1609144
Oct 12 2012
parent reply "denizzzka" <4denizzz gmail.com> writes:
On Friday, 12 October 2012 at 23:30:39 UTC, Sean Kelly wrote:

 
 I would be grateful if someone share singly linked list based 
 on cas()
There's a sample Stack and SList implementation in the concurrency chapter: http://www.informit.com/articles/printerfriendly.aspx?p=1609144
Of course, I read this article. I think that SList is not the same thing as FIFO list - get the first entry in the queue and get queue entry by numerical order are two different things in multithreaded environment, right? I think its necessary to implement "primitives" like a CASN from article "A Pratial Multi-Word Compare-and-Swap Operation" (by Timothy L. Harris, Keir Fraser and Ian A. Pratt.) This titanic challenge as I see it, but sooner or later it will have to do. Then we will be able to create various thread safe structures.
Oct 13 2012
parent "denizzzka" <4denizzz gmail.com> writes:
Not that the "titanic" but the authors, probably, have used Java 
and another type of cas result returns.
Oct 13 2012