lemon/bits/lock.h
branch1.3
changeset 1178 e5af35e6c93f
parent 979 43a91b33f374
equal deleted inserted replaced
0:1f20ebf25a91 1:37b17b044ccc
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     2  *
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library.
     3  * This file is a part of LEMON, a generic C++ optimization library.
     4  *
     4  *
     5  * Copyright (C) 2003-2012
     5  * Copyright (C) 2003-2013
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     8  *
     9  * Permission to use, modify and distribute this software is granted
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    10  * provided that this copyright notice appears in all copies. For
    31 
    31 
    32 #if defined(LEMON_USE_PTHREAD)
    32 #if defined(LEMON_USE_PTHREAD)
    33     class Lock {
    33     class Lock {
    34     public:
    34     public:
    35       Lock() {
    35       Lock() {
    36 	pthread_mutex_init(&_lock, 0);
    36         pthread_mutex_init(&_lock, 0);
    37       }
    37       }
    38       ~Lock() {
    38       ~Lock() {
    39 	pthread_mutex_destroy(&_lock);
    39         pthread_mutex_destroy(&_lock);
    40       }
    40       }
    41       void lock() {
    41       void lock() {
    42 	pthread_mutex_lock(&_lock);
    42         pthread_mutex_lock(&_lock);
    43       }
    43       }
    44       void unlock() {
    44       void unlock() {
    45 	pthread_mutex_unlock(&_lock);
    45         pthread_mutex_unlock(&_lock);
    46       }
    46       }
    47 
    47 
    48     private:
    48     private:
    49       pthread_mutex_t _lock;
    49       pthread_mutex_t _lock;
    50     };
    50     };
    55     public:
    55     public:
    56       Lock() {}
    56       Lock() {}
    57       ~Lock() {}
    57       ~Lock() {}
    58       void lock() {}
    58       void lock() {}
    59       void unlock() {}
    59       void unlock() {}
    60     };    
    60     };
    61 #endif
    61 #endif
    62   }
    62   }
    63 }
    63 }
    64 
    64 
    65 #endif
    65 #endif