COIN-OR::LEMON - Graph Library

Ignore:
Location:
lemon
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lemon/cplex.cc

    r1349 r1336  
    3838  }
    3939
    40   void CplexEnv::incCnt()
    41   {
    42     _cnt_lock->lock();
     40  CplexEnv::CplexEnv() {
     41    int status;
     42    _cnt = new int;
     43    (*_cnt) = 1;
     44    _env = CPXopenCPLEX(&status);
     45    if (_env == 0) {
     46      delete _cnt;
     47      _cnt = 0;
     48      throw LicenseError(status);
     49    }
     50  }
     51
     52  CplexEnv::CplexEnv(const CplexEnv& other) {
     53    _env = other._env;
     54    _cnt = other._cnt;
    4355    ++(*_cnt);
    44     _cnt_lock->unlock();
    45   }
    46 
    47   void CplexEnv::decCnt()
    48   {
    49     _cnt_lock->lock();
     56  }
     57
     58  CplexEnv& CplexEnv::operator=(const CplexEnv& other) {
     59    _env = other._env;
     60    _cnt = other._cnt;
     61    ++(*_cnt);
     62    return *this;
     63  }
     64
     65  CplexEnv::~CplexEnv() {
    5066    --(*_cnt);
    5167    if (*_cnt == 0) {
    5268      delete _cnt;
    53       _cnt_lock->unlock();
    54       delete _cnt_lock;
    5569      CPXcloseCPLEX(&_env);
    5670    }
    57     else _cnt_lock->unlock();
    58   }
    59  
    60   CplexEnv::CplexEnv() {
    61     int status;
    62     _env = CPXopenCPLEX(&status);
    63     if (_env == 0)
    64       throw LicenseError(status);
    65     _cnt = new int;
    66     (*_cnt) = 1;
    67     _cnt_lock = new bits::Lock;
    68   }
    69 
    70   CplexEnv::CplexEnv(const CplexEnv& other) {
    71     _env = other._env;
    72     _cnt = other._cnt;
    73     _cnt_lock = other._cnt_lock;
    74     incCnt();
    75   }
    76 
    77   CplexEnv& CplexEnv::operator=(const CplexEnv& other) {
    78     decCnt();
    79     _env = other._env;
    80     _cnt = other._cnt;
    81     _cnt_lock = other._cnt_lock;
    82     incCnt();
    83     return *this;
    84   }
    85 
    86   CplexEnv::~CplexEnv() {
    87     decCnt();
    8871  }
    8972
  • lemon/cplex.h

    r1347 r1270  
    2424
    2525#include <lemon/lp_base.h>
    26 #include <lemon/bits/lock.h>
    2726
    2827struct cpxenv;
     
    4241    cpxenv* _env;
    4342    mutable int* _cnt;
    44     mutable bits::Lock* _cnt_lock;
    45 
    46     void incCnt();
    47     void decCnt();
    48    
     43
    4944  public:
    5045
Note: See TracChangeset for help on using the changeset viewer.