Magick++ 7.1.2-32
Convert, Edit, Or Compose Bitmap Images
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 31 of file Thread.h.

Constructor & Destructor Documentation

◆ MutexLock()

Magick::MutexLock::MutexLock ( void )

Definition at line 19 of file Thread.cpp.

22 : _mutex()
23{
24 ::pthread_mutexattr_t
25 attr;
26
27 int
28 sysError;
29
30 if ((sysError=::pthread_mutexattr_init(&attr)) == 0)
31 if ((sysError=::pthread_mutex_init(&_mutex,&attr)) == 0)
32 {
33 ::pthread_mutexattr_destroy(&attr);
34 return;
35 }
36 throwExceptionExplicit(MagickCore::OptionError,"mutex initialization failed",
37 strerror(sysError));
38}
39#else
40#if defined(_VISUALC_) && defined(_MT)
41// Win32 threads
42{
43 SECURITY_ATTRIBUTES
44 security;
45
46 /* Allow the semaphore to be inherited */
47 security.nLength=sizeof(security);
48 security.lpSecurityDescriptor=(LPVOID) NULL;
49 security.bInheritHandle=TRUE;
50
51 /* Create the semaphore, with initial value signaled */
52 _mutex=::CreateSemaphore(&security,1,1,(LPCSTR) NULL);
53 if (_mutex != (HANDLE) NULL)
54 return;
55 throwExceptionExplicit(MagickCore::OptionError,
56 "mutex initialization failed");
57}
58#else
59// Threads not supported
60{
61}

◆ ~MutexLock()

Magick::MutexLock::~MutexLock ( void )

Definition at line 66 of file Thread.cpp.

67{
68#if defined(MAGICKCORE_HAVE_PTHREAD)
69 (void) ::pthread_mutex_destroy(&_mutex);
70#endif
71#if defined(_MT) && defined(_VISUALC_)
72 (void) ::CloseHandle(_mutex);
73#endif
74}

Member Function Documentation

◆ lock()

void Magick::MutexLock::lock ( void )

Definition at line 77 of file Thread.cpp.

78{
79#if defined(MAGICKCORE_HAVE_PTHREAD)
80 int
81 sysError;
82
83 if ((sysError=::pthread_mutex_lock(&_mutex)) == 0)
84 return;
85 throwExceptionExplicit(MagickCore::OptionError,"mutex lock failed",
86 strerror(sysError));
87#endif
88#if defined(_MT) && defined(_VISUALC_)
89 if (WaitForSingleObject(_mutex,INFINITE) != WAIT_FAILED)
90 return;
91 throwExceptionExplicit(MagickCore::OptionError,"mutex lock failed");
92#endif
93}

◆ unlock()

void Magick::MutexLock::unlock ( void )

Definition at line 96 of file Thread.cpp.

97{
98#if defined(MAGICKCORE_HAVE_PTHREAD)
99 int
100 sysError;
101
102 if ((sysError=::pthread_mutex_unlock(&_mutex)) == 0)
103 return;
104 throwExceptionExplicit(MagickCore::OptionError,"mutex unlock failed",
105 strerror(sysError));
106#endif
107#if defined(_MT) && defined(_VISUALC_)
108 if (ReleaseSemaphore(_mutex,1,(LPLONG) NULL) == TRUE)
109 return;
110 throwExceptionExplicit(MagickCore::OptionError,"mutex unlock failed");
111#endif
112}

The documentation for this class was generated from the following files:
  • /home/cristy/Attic/Build/ImageMagick-7.1.2/rpmbuild/BUILD/ImageMagick-7.1.2-build/ImageMagick-7.1.2-32/Magick++/lib/Magick++/Thread.h
  • /home/cristy/Attic/Build/ImageMagick-7.1.2/rpmbuild/BUILD/ImageMagick-7.1.2-build/ImageMagick-7.1.2-32/Magick++/lib/Thread.cpp