Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
Mutex Struct Reference
Collaboration diagram for Mutex:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Mutex (const char *name)
 ~Mutex ()
BOOL Lock (DWORD timeout)
void Unlock ()
 Mutex (const char *name)
 ~Mutex ()
BOOL Lock (DWORD timeout)
void Unlock ()
 Mutex (const char *name)
 ~Mutex ()
BOOL Lock (DWORD timeout)
void Unlock ()
 Mutex (const char *name)
 ~Mutex ()
BOOL Lock (DWORD timeout)
void Unlock ()

Private Attributes

nsCString mName
HMTX mHandle
DWORD mState
HANDLE mHandle

Detailed Description

Definition at line 160 of file nsNativeAppSupportOS2.cpp.


Constructor & Destructor Documentation

Mutex::Mutex ( const char *  name) [inline]

Definition at line 161 of file nsNativeAppSupportOS2.cpp.

        : mName( name ),
          mHandle( 0 ),
          mState( 0xFFFF ) {
        /* OS/2 named semaphores must begin with "\\SEM32\\" to be valid */
        mName.Insert("\\SEM32\\", 0);
        APIRET rc = DosCreateMutexSem(mName.get(), &mHandle, 0, FALSE);
        if (rc != NO_ERROR) {
#if MOZ_DEBUG_DDE
            printf("CreateMutex error = 0x%08X\n", (int)rc);
#endif
        }
    }

Here is the call graph for this function:

Mutex::~Mutex ( ) [inline]

Definition at line 174 of file nsNativeAppSupportOS2.cpp.

             {
        if ( mHandle ) {
            // Make sure we release it if we own it.
            Unlock();

            APIRET rc = DosCloseMutexSem(mHandle);
            if (rc != NO_ERROR) {
#if MOZ_DEBUG_DDE
                printf("CloseHandle error = 0x%08X\n", (int)rc);
#endif
            }
        }
    }

Here is the call graph for this function:

Mutex::Mutex ( const char *  name) [inline]

Definition at line 133 of file nsNativeAppSupportWin.cpp.

        : mName( name ),
          mHandle( 0 ),
          mState( -1 ) {
        mHandle = CreateMutex( 0, FALSE, mName.get() );
#if MOZ_DEBUG_DDE
        printf( "CreateMutex error = 0x%08X\n", (int)GetLastError() );
#endif
    }

Here is the call graph for this function:

Mutex::~Mutex ( ) [inline]

Definition at line 142 of file nsNativeAppSupportWin.cpp.

             {
        if ( mHandle ) {
            // Make sure we release it if we own it.
            Unlock();

            BOOL rc = CloseHandle( mHandle );
#if MOZ_DEBUG_DDE
            if ( !rc ) {
                printf( "CloseHandle error = 0x%08X\n", (int)GetLastError() );
            }
#endif
        }
    }

Here is the call graph for this function:

Mutex::Mutex ( const char *  name) [inline]

Definition at line 229 of file nsNativeAppSupportOS2.cpp.

        : mName( name ),
          mHandle( 0 ),
          mState( 0xFFFF ) {
        /* OS/2 named semaphores must begin with "\\SEM32\\" to be valid */
        mName.Insert("\\SEM32\\", 0);
        APIRET rc = DosCreateMutexSem(mName.get(), &mHandle, 0, FALSE);
        if (rc != NO_ERROR) {
#if MOZ_DEBUG_DDE
            printf( "CreateMutex error = 0x%08X\n", (int)rc );
#endif
        }
    }

Here is the call graph for this function:

Mutex::~Mutex ( ) [inline]

Definition at line 242 of file nsNativeAppSupportOS2.cpp.

             {
        if ( mHandle ) {
            // Make sure we release it if we own it.
            Unlock();


            APIRET rc = DosCloseMutexSem(mHandle);
            if (rc != NO_ERROR) {
#if MOZ_DEBUG_DDE
                printf( "CloseHandle error = 0x%08X\n", (int)rc );
#endif
            }
        }
    }

Here is the call graph for this function:

Mutex::Mutex ( const char *  name) [inline]

Definition at line 239 of file nsNativeAppSupportWin.cpp.

        : mName( name ),
          mHandle( 0 ),
          mState( -1 ) {
        mHandle = CreateMutex( 0, FALSE, mName.get() );
#if MOZ_DEBUG_DDE
        printf( "CreateMutex error = 0x%08X\n", (int)GetLastError() );
#endif
    }

Here is the call graph for this function:

Mutex::~Mutex ( ) [inline]

Definition at line 248 of file nsNativeAppSupportWin.cpp.

             {
        if ( mHandle ) {
            // Make sure we release it if we own it.
            Unlock();

            BOOL rc = CloseHandle( mHandle );
#if MOZ_DEBUG_DDE
            if ( !rc ) {
                printf( "CloseHandle error = 0x%08X\n", (int)GetLastError() );
            }
#endif
        }
    }

Here is the call graph for this function:


Member Function Documentation

BOOL Mutex::Lock ( DWORD  timeout) [inline]

Definition at line 155 of file nsNativeAppSupportWin.cpp.

                               {
        if ( mHandle ) {
#if MOZ_DEBUG_DDE
            printf( "Waiting (%d msec) for DDE mutex...\n", (int)timeout );
#endif
            mState = WaitForSingleObject( mHandle, timeout );
#if MOZ_DEBUG_DDE
            printf( "...wait complete, result = 0x%08X, GetLastError=0x%08X\n", (int)mState, (int)::GetLastError() );
#endif
            return mState == WAIT_OBJECT_0 || mState == WAIT_ABANDONED;
        } else {
            return FALSE;
        }
    }
BOOL Mutex::Lock ( DWORD  timeout) [inline]

Definition at line 187 of file nsNativeAppSupportOS2.cpp.

                               {
        if ( mHandle ) {
#if MOZ_DEBUG_DDE
            printf( "Waiting (%d msec) for DDE mutex...\n", (int)timeout );
#endif
            mState = DosRequestMutexSem( mHandle, timeout );
#if MOZ_DEBUG_DDE
            printf( "...wait complete, result = 0x%08X\n", (int)mState );
#endif
            return (mState == NO_ERROR);
        } else {
            return FALSE;
        }
    }

Here is the caller graph for this function:

BOOL Mutex::Lock ( DWORD  timeout) [inline]

Definition at line 256 of file nsNativeAppSupportOS2.cpp.

                               {
        if ( mHandle ) {
#if MOZ_DEBUG_DDE
            printf( "Waiting (%d msec) for DDE mutex...\n", (int)timeout );
#endif
            mState = DosRequestMutexSem( mHandle, timeout );
#if MOZ_DEBUG_DDE
            printf( "...wait complete, result = 0x%08X\n", (int)mState );
#endif
            return (mState == NO_ERROR);
        } else {
            return FALSE;
        }
    }
BOOL Mutex::Lock ( DWORD  timeout) [inline]

Definition at line 261 of file nsNativeAppSupportWin.cpp.

                               {
        if ( mHandle ) {
#if MOZ_DEBUG_DDE
            printf( "Waiting (%d msec) for DDE mutex...\n", (int)timeout );
#endif
            mState = WaitForSingleObject( mHandle, timeout );
#if MOZ_DEBUG_DDE
            printf( "...wait complete, result = 0x%08X, GetLastError=0x%08X\n", (int)mState, (int)::GetLastError() );
#endif
            return mState == WAIT_OBJECT_0 || mState == WAIT_ABANDONED;
        } else {
            return FALSE;
        }
    }
void Mutex::Unlock ( void  ) [inline]

Definition at line 169 of file nsNativeAppSupportWin.cpp.

                  {
        if ( mHandle && mState == WAIT_OBJECT_0 ) {
#if MOZ_DEBUG_DDE
            printf( "Releasing DDE mutex\n" );
#endif
            ReleaseMutex( mHandle );
            mState = -1;
        }
    }
void Mutex::Unlock ( void  ) [inline]

Definition at line 201 of file nsNativeAppSupportOS2.cpp.

                  {
        if ( mHandle && mState == NO_ERROR ) {
#if MOZ_DEBUG_DDE
            printf( "Releasing DDE mutex\n" );
#endif
            DosReleaseMutexSem( mHandle );
            mState = 0xFFFF;
        }
    }

Here is the caller graph for this function:

void Mutex::Unlock ( void  ) [inline]

Definition at line 270 of file nsNativeAppSupportOS2.cpp.

                  {
        if ( mHandle && mState == NO_ERROR ) {
#if MOZ_DEBUG_DDE
            printf( "Releasing DDE mutex\n" );
#endif
            DosReleaseMutexSem( mHandle );
            mState = 0xFFFF;
        }
    }
void Mutex::Unlock ( void  ) [inline]

Definition at line 275 of file nsNativeAppSupportWin.cpp.

                  {
        if ( mHandle && mState == WAIT_OBJECT_0 ) {
#if MOZ_DEBUG_DDE
            printf( "Releasing DDE mutex\n" );
#endif
            ReleaseMutex( mHandle );
            mState = -1;
        }
    }

Member Data Documentation

Definition at line 180 of file nsNativeAppSupportWin.cpp.

Definition at line 212 of file nsNativeAppSupportOS2.cpp.

Definition at line 211 of file nsNativeAppSupportOS2.cpp.

DWORD Mutex::mState [private]

Definition at line 213 of file nsNativeAppSupportOS2.cpp.


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