COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/bits/windows.cc

    r956 r1270  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2010
     5 * Copyright (C) 2003-2013
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    4141#include <unistd.h>
    4242#include <ctime>
     43#ifndef WIN32
    4344#include <sys/times.h>
     45#endif
    4446#include <sys/time.h>
    4547#endif
     
    129131#endif
    130132    }
     133
     134    WinLock::WinLock() {
     135#ifdef WIN32
     136      CRITICAL_SECTION *lock = new CRITICAL_SECTION;
     137      InitializeCriticalSection(lock);
     138      _repr = lock;
     139#else
     140      _repr = 0; //Just to avoid 'unused variable' warning with clang
     141#endif
     142    }
     143
     144    WinLock::~WinLock() {
     145#ifdef WIN32
     146      CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
     147      DeleteCriticalSection(lock);
     148      delete lock;
     149#endif
     150    }
     151
     152    void WinLock::lock() {
     153#ifdef WIN32
     154      CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
     155      EnterCriticalSection(lock);
     156#endif
     157    }
     158
     159    void WinLock::unlock() {
     160#ifdef WIN32
     161      CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
     162      LeaveCriticalSection(lock);
     163#endif
     164    }
    131165  }
    132166}
Note: See TracChangeset for help on using the changeset viewer.