Loading...
Searching...
No Matches
Magick::MutexLock Class Reference

## Public Member Functions

void | lock (void)
void | unlock (void)

## Private Member Functions

| MutexLock (const MutexLock &original_)
MutexLock & | operator= (const MutexLock &original)

## Detailed Description

Definition at line 29 of file Thread.h.

## Constructor & Destructor Documentation

## MutexLock()

Magick::MutexLock::MutexLock | ( | void |  | ) |

Definition at line 20 of file Thread.cpp.

: _mutex()
{
::pthread_mutexattr_t
attr;
int
sysError;
if ((sysError=::pthread_mutexattr_init(&attr)) == 0)
if ((sysError=::pthread_mutex_init(&_mutex,&attr)) == 0)
{
::pthread_mutexattr_destroy(&attr);
return;
}
throwExceptionExplicit(MagickCore::OptionError,"mutex initialization failed",
strerror(sysError));
}
#else
#if defined(_VISUALC_) && defined(_MT)
// Win32 threads
{
SECURITY_ATTRIBUTES
security;
/* Allow the semaphore to be inherited */
security.nLength=sizeof(security);
security.lpSecurityDescriptor=(LPVOID) NULL;
security.bInheritHandle=TRUE;
/* Create the semaphore, with initial value signaled */
_mutex=::CreateSemaphore(&security,1,1,(LPCSTR) NULL);
if (_mutex != (HANDLE) NULL)
return;
throwExceptionExplicit(MagickCore::OptionError,
"mutex initialization failed");
}
#else
// Threads not supported
{
}

## ~MutexLock()

Magick::MutexLock::~MutexLock | ( | void |  | ) |

Definition at line 67 of file Thread.cpp.

{
#if defined(MAGICKCORE_HAVE_PTHREAD)
(void) ::pthread_mutex_destroy(&_mutex);
#endif
#if defined(_MT) && defined(_VISUALC_)
(void) ::CloseHandle(_mutex);
#endif
}

## Member Function Documentation

## lock()

void Magick::MutexLock::lock | ( | void |  | ) |

Definition at line 78 of file Thread.cpp.

{
#if defined(MAGICKCORE_HAVE_PTHREAD)
int
sysError;
if ((sysError=::pthread_mutex_lock(&_mutex)) == 0)
return;
throwExceptionExplicit(MagickCore::OptionError,"mutex lock failed",
strerror(sysError));
#endif
#if defined(_MT) && defined(_VISUALC_)
if (WaitForSingleObject(_mutex,INFINITE) != WAIT_FAILED)
return;
throwExceptionExplicit(MagickCore::OptionError,"mutex lock failed");
#endif
}

## unlock()

void Magick::MutexLock::unlock | ( | void |  | ) |

Definition at line 97 of file Thread.cpp.

{
#if defined(MAGICKCORE_HAVE_PTHREAD)
int
sysError;
if ((sysError=::pthread_mutex_unlock(&_mutex)) == 0)
return;
throwExceptionExplicit(MagickCore::OptionError,"mutex unlock failed",
strerror(sysError));
#endif
#if defined(_MT) && defined(_VISUALC_)
if (ReleaseSemaphore(_mutex,1,(LPLONG) NULL) == TRUE)
return;
throwExceptionExplicit(MagickCore::OptionError,"mutex unlock failed");
#endif
}

The documentation for this class was generated from the following files:

- /build/imagemagick-icbe39/imagemagick-7.1.2.3+dfsg1/Magick++/lib/Magick++/Thread.h
- /build/imagemagick-icbe39/imagemagick-7.1.2.3+dfsg1/Magick++/lib/Thread.cpp