|
Archives
D Programming
digitalmars.Ddigitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger D.gnu D C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
digitalmars.D.learn - Synchronized Linked List Traversal
I'm working on a project that requires multi-threading and I am trying to grasp
the best way to work with setting up a linked-list where multiple threads might
try to be setting the next element in the list at the same time.
What I really need to know is if this will work:
Node!(T) child = parent.firstChild;
synchronized (child)
{
while (child.sibling !is null)
child = child.sibling;
child.sibling = node;
}
What I am worried about is that the mutex will not follow the traversal. Any
help would be great.
Thanks you,
Jonathan
Jan 20 2010
On Wed, 20 Jan 2010 19:25:27 -0500, Jonathan Crapuchettes <jcrapuchettes gmail.com> wrote: Jan 21 2010
Thank you for the help. Since I am using D1, I think I will use the pthread mutexes through the C API. Steven Schveighoffer wrote:On Thu, 21 Jan 2010 08:35:50 -0500, Steven Schveighoffer <schveiguy yahoo.com> wrote:To do this, you need a manual mutex, look in tango.core.sync.Mutex I think. Jan 21 2010
Yeah, but I have a lot of code in this project that uses phobos and it would be a major pain (not to mention the time) to switch over. Thank you for the thought, Jonathan Steven Schveighoffer wrote:On Thu, 21 Jan 2010 13:29:37 -0500, Jonathan Crapuchettes <jcrapuchettes gmail.com> wrote:Thank you for the help. Since I am using D1, I think I will use the pthread mutexes through the C API. Jan 21 2010
On Thu, 21 Jan 2010 08:35:50 -0500, Steven Schveighoffer <schveiguy yahoo.com> wrote:To do this, you need a manual mutex, look in tango.core.sync.Mutex I think. Jan 21 2010
On Thu, 21 Jan 2010 13:29:37 -0500, Jonathan Crapuchettes <jcrapuchettes gmail.com> wrote:Thank you for the help. Since I am using D1, I think I will use the pthread mutexes through the C API. Jan 21 2010
On Thu, 21 Jan 2010 13:44:53 -0500, Jonathan Crapuchettes <jcrapuchettes gmail.com> wrote:Yeah, but I have a lot of code in this project that uses phobos and it would be a major pain (not to mention the time) to switch over. Thank you for the thought, Jonathan Jan 21 2010
|