Powered by Pair ImageMagick logo
Image Magick
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages

Magick::MutexLock Class Reference

#include <Thread.h>


Public Member Functions

 MutexLock (void)
 ~MutexLock (void)
void lock (void)
void unlock (void)

Private Member Functions

 MutexLock (const MutexLock &original_)
MutexLockoperator= (const MutexLock &original_)


Constructor & Destructor Documentation

Magick::MutexLock::MutexLock void   ) 
 

Definition at line 16 of file Thread.cpp.

References OptionError, and Magick::throwExceptionExplicit().

00019 : _mutex() 00020 { 00021 ::pthread_mutexattr_t attr; 00022 int sysError; 00023 if ( (sysError = ::pthread_mutexattr_init( &attr )) == 0 ) 00024 if ( (sysError = ::pthread_mutex_init( &_mutex, &attr )) == 0 ) 00025 { 00026 ::pthread_mutexattr_destroy( &attr ); 00027 return; 00028 } 00029 throwExceptionExplicit( OptionError, "mutex initialization failed", 00030 strerror(sysError) ); 00031 } 00032 #else 00033 #if defined(_VISUALC_) && defined(_MT) 00034 // Win32 threads 00035 : _mutex() 00036 { 00037 SECURITY_ATTRIBUTES security; 00038 00039 /* Allow the semaphore to be inherited */ 00040 security.nLength = sizeof(security); 00041 security.lpSecurityDescriptor = NULL; 00042 security.bInheritHandle = TRUE; 00043 00044 /* Create the semaphore, with initial value signaled */ 00045 _mutex.id = ::CreateSemaphore(&security, 1, MAXSEMLEN, NULL); 00046 if ( _mutex.id != NULL ) 00047 return; 00048 throwExceptionExplicit( OptionError, "mutex initialization failed" ); 00049 } 00050 #else 00051 // Threads not supported 00052 { 00053 }

Here is the call graph for this function:

Magick::MutexLock::~MutexLock void   ) 
 

Definition at line 58 of file Thread.cpp.

References OptionError, and Magick::throwExceptionExplicit().

00059 { 00060 #if defined(HasPTHREADS) 00061 int sysError; 00062 if ( (sysError = ::pthread_mutex_destroy( &_mutex )) == 0 ) 00063 return; 00064 throwExceptionExplicit( OptionError, "mutex destruction failed", 00065 strerror(sysError) ); 00066 #endif 00067 #if defined(_MT) && defined(_VISUALC_) 00068 if ( ::CloseHandle(_mutex.id) != 0 ) 00069 return; 00070 throwExceptionExplicit( OptionError, "mutex destruction failed" ); 00071 #endif 00072 }

Here is the call graph for this function:

Magick::MutexLock::MutexLock const MutexLock original_  )  [private]
 


Member Function Documentation

void Magick::MutexLock::lock void   ) 
 

Definition at line 75 of file Thread.cpp.

References OptionError, and Magick::throwExceptionExplicit().

Referenced by Magick::Lock::Lock().

00076 { 00077 #if defined(HasPTHREADS) 00078 int sysError; 00079 if ( (sysError = ::pthread_mutex_lock( &_mutex )) == 0) 00080 return; 00081 throwExceptionExplicit( OptionError, "mutex lock failed", 00082 strerror(sysError)); 00083 #endif 00084 #if defined(_MT) && defined(_VISUALC_) 00085 if (WaitForSingleObject(_mutex.id,INFINITE) != WAIT_FAILED) 00086 return; 00087 throwExceptionExplicit( OptionError, "mutex lock failed" ); 00088 #endif 00089 }

Here is the call graph for this function:

MutexLock& Magick::MutexLock::operator= const MutexLock original_  )  [private]
 

void Magick::MutexLock::unlock void   ) 
 

Definition at line 92 of file Thread.cpp.

References OptionError, and Magick::throwExceptionExplicit().

Referenced by Magick::Lock::~Lock().

00093 { 00094 #if defined(HasPTHREADS) 00095 int sysError; 00096 if ( (sysError = ::pthread_mutex_unlock( &_mutex )) == 0) 00097 return; 00098 throwExceptionExplicit( OptionError, "mutex unlock failed", 00099 strerror(sysError) ); 00100 #endif 00101 #if defined(_MT) && defined(_VISUALC_) 00102 if ( ReleaseSemaphore(_mutex.id, 1, NULL) == TRUE ) 00103 return; 00104 throwExceptionExplicit( OptionError, "mutex unlock failed" ); 00105 #endif 00106 }

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated on Mon Oct 25 13:48:31 2004 for ImageMagick by doxygen 1.3.7
ImageMagick Copyright © 2004, ImageMagick Studio LLC