recursive mutexes

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Shaeto
Posts: 140
Joined: Tue, 2009-01-20, 17:50
Location: CA, USA
Contact:

recursive mutexes

#1 Post by Shaeto » Tue, 2009-06-16, 19:49

if it possible, please add option for OFMutex to create recursive mutexes, something like:

OFMutex::OFMutex(OFBool recursive)
: theMutex(NULL)
{
#ifdef WINDOWS_INTERFACE
theMutex = (void *)(CreateMutex(NULL, FALSE, NULL));
#elif defined(POSIX_INTERFACE)
pthread_mutex_t *mtx = new pthread_mutex_t;
if (mtx)
{
pthread_mutexattr_t _attr;

if (recursive) {
pthread_mutexattr_init(&_attr);
pthread_mutexattr_settype(&_attr, PTHREAD_MUTEX_RECURSIVE);
}
if (pthread_mutex_init(mtx, recursive ? &_attr : NULL)) delete mtx;
else theMutex = mtx;
}
#elif defined(SOLARIS_INTERFACE)
// i am not sure how to init recursive mutexes under solaris
// seems like 2.6-- kernels dont support this type
mutex_t *mtx = new mutex_t;
if (mtx)
{
if (mutex_init(mtx, USYNC_THREAD, NULL)) delete mtx;
else theMutex = mtx;
}
#else
#endif
}


-----------------

Thanks!

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest