VIZ++ Class: CriticalSection

 VIZ++ Class Library  VIZ++ Samples  VIZ++ ClassTree 

Source code

/*
 * CriticalSection.h 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


#pragma once
#include <viz++\Object.h>


namespace VIZ {

class CriticalSection :public Object {
private:
  CRITICAL_SECTION cs;

public:
  CriticalSection() {
      ::InitializeCriticalSection(&cs);
  }

  ~CriticalSection() {
      ::DeleteCriticalSection(&cs);
  }
  void   enter() {
      ::EnterCriticalSection(&cs);
  }

  BOOL tryEnter() {
    return TryEnterCriticalSection(&cs);
  }

  void   leave() {
      ::LeaveCriticalSection(&cs);
  }
};

}


Last modified: 10 Feb 2017

Copyright (c) 2009-2017 Antillia.com ALL RIGHTS RESERVED.