Ignore:
Timestamp:
Jul 24, 2002, 11:49:43 PM (23 years ago)
Author:
umoeller
Message:

Mutex modifications.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/except.c

    r164 r191  
    117117 *
    118118 *      As a result, you should protect any section of code which
    119  *      requests a semaphore with the exception handlers. To protect
    120  *      yourself against thread termination, use must-complete
    121  *      sections as well (but be careful with those if your code
    122  *      takes a long time to execute... but then you shouldn't
    123  *      request a mutex in the first place).
     119 *      requests a semaphore with the exception handlers.
    124120 *
    125121 *      So _whenever_ you request a mutex semaphore, enclose
     
    133129 +          {
    134130 +              BOOL    fSemOwned = FALSE;
    135  +              ULONG   ulNesting = 0;
    136131 +
    137  +              DosEnterMustComplete(&ulNesting);
    138132 +              TRY_QUIET(excpt1)           // or TRY_LOUD
    139133 +              {
    140  +                  fSemOwned = !WinRequestMutexSem(hmtx, ...);
    141  +                  if (fSemOwned)
     134 +                  if (fSemOwned = !DosRequestMutexSem(hmtx, ...))
    142135 +                  {       ... // work on your protected data
    143136 +                  }
     
    147140 +
    148141 +              if (fSemOwned)
    149  +              {
    150142 +                  // this gets executed always, even if an exception occured
    151143 +                  DosReleaseMutexSem(hmtx);
    152  +                  fSemOwned = FALSE;
    153  +              }
    154  +              DosExitMustComplete(&ulNesting);
    155144 +          } // end of your_func
    156145 *
Note: See TracChangeset for help on using the changeset viewer.