lemon/bits/windows.cc
changeset 984 fcb6ad1e67d0
parent 941 6660ac776acf
child 1001 e344f0887c59
equal deleted inserted replaced
4:9bd3c1e3b6e5 5:4b80af21663d
   128       timeval tv;
   128       timeval tv;
   129       gettimeofday(&tv, 0);
   129       gettimeofday(&tv, 0);
   130       return getpid() + tv.tv_sec + tv.tv_usec;
   130       return getpid() + tv.tv_sec + tv.tv_usec;
   131 #endif
   131 #endif
   132     }
   132     }
       
   133 
       
   134     WinLock::WinLock() {
       
   135 #ifdef WIN32
       
   136       CRITICAL_SECTION *lock = new CRITICAL_SECTION;
       
   137       InitializeCriticalSection(lock);
       
   138       _repr = lock;
       
   139 #endif
       
   140     }
       
   141     
       
   142     WinLock::~WinLock() {
       
   143 #ifdef WIN32
       
   144       CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
       
   145       DeleteCriticalSection(lock);
       
   146       delete lock;
       
   147 #endif
       
   148     }
       
   149 
       
   150     void WinLock::lock() {
       
   151 #ifdef WIN32
       
   152       CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
       
   153       EnterCriticalSection(lock);
       
   154 #endif
       
   155     }
       
   156 
       
   157     void WinLock::unlock() {
       
   158 #ifdef WIN32
       
   159       CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
       
   160       LeaveCriticalSection(lock);
       
   161 #endif
       
   162     }
   133   }
   163   }
   134 }
   164 }