Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1997.
  5. //
  6. // Class: CNonUnwindableLock (lck)
  7. //
  8. // Purpose: Lock using a Mutex Semaphore
  9. //
  10. // History: 02-Oct-91 BartoszM Created.
  11. //
  12. // Notes: Simple lock object to be created on the stack.
  13. // The constructor acquires the semaphor, the destructor
  14. // (called when lock is going out of scope) releases it.
  15. //
  16. // operator delete cannot change the unwind stack.
  17. //
  18. //----------------------------------------------------------------------------
  19. #pragma once
  20. #ifndef EXCEPT_TEST
  21. class CNonUnwindableLock
  22. {
  23. public:
  24. inline CNonUnwindableLock ( CMutexSem& mxs );
  25. inline ~CNonUnwindableLock ();
  26. private:
  27. CMutexSem& _mxs;
  28. };
  29. //+---------------------------------------------------------------------------
  30. //
  31. // Member: CNonUnwindableLock::CNonUnwindableLock
  32. //
  33. // Synopsis: Acquire semaphore
  34. //
  35. // History: 02-Oct-91 BartoszM Created.
  36. //
  37. //----------------------------------------------------------------------------
  38. inline CNonUnwindableLock::CNonUnwindableLock ( CMutexSem& mxs )
  39. : _mxs ( mxs )
  40. {
  41. _mxs.Request();
  42. }
  43. //+---------------------------------------------------------------------------
  44. //
  45. // Member: CNonUnwindableLock::~CNonUnwindableLock
  46. //
  47. // Synopsis: Release semaphore
  48. //
  49. // History: 02-Oct-91 BartoszM Created.
  50. //
  51. //----------------------------------------------------------------------------
  52. inline CNonUnwindableLock::~CNonUnwindableLock ()
  53. {
  54. _mxs.Release();
  55. }
  56. #endif // EXCEPT_TEST