Subj : Re: Lock free t-safe smart pointer based on double linked list To : comp.programming.threads From : Joe Seigh Date : Fri May 13 2005 09:07 am On 12 May 2005 22:20:56 -0700, axter wrote: > > rGlory wrote: >> >> There is another problem though. To use such structure as SP I need > to >> put a pointer into struct item. It is not clear to me how to safely >> assign such pointer when "everything can change any time". >> >> Any ideas? > > For a thread safe C++ smart pointer, check out the following link: > http://code.axter.com/sync_ptr.h > > The sync_ptr smart pointer is a wrapper class that can make the > instance of any object thread safe. In windows it can use critical > section logic or mutex, and in UNIX/Linux it uses POSIX mutex logic. > > How do you avoid deadlock? thread 1: x->f(&(y->g()); thread 2: y->f(&(x->g()); -- Joe Seigh When you get lemons, you make lemonade. When you get hardware, you make software. .