lemon/bits/lock.h
author Peter Kovacs <kpeter@inf.elte.hu>
Sat, 07 Oct 2017 16:22:04 +0200
changeset 1193 3ca508482e4c
parent 979 43a91b33f374
permissions -rw-r--r--
Change misleading method name in Vf2pp (#597)

It processes an entire connected component of the graph _g1 using BFS,
so processBfsTree() is more appropriate name than processBFSLevel().
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library.
     4  *
     5  * Copyright (C) 2003-2013
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    11  * precise terms see the accompanying LICENSE file.
    12  *
    13  * This software is provided "AS IS" with no warranty of any kind,
    14  * express or implied, and with no claim as to its suitability for any
    15  * purpose.
    16  *
    17  */
    18 
    19 #ifndef LEMON_BITS_LOCK_H
    20 #define LEMON_BITS_LOCK_H
    21 
    22 #include <lemon/config.h>
    23 #if defined(LEMON_USE_PTHREAD)
    24 #include <pthread.h>
    25 #elif defined(LEMON_USE_WIN32_THREADS)
    26 #include <lemon/bits/windows.h>
    27 #endif
    28 
    29 namespace lemon {
    30   namespace bits {
    31 
    32 #if defined(LEMON_USE_PTHREAD)
    33     class Lock {
    34     public:
    35       Lock() {
    36         pthread_mutex_init(&_lock, 0);
    37       }
    38       ~Lock() {
    39         pthread_mutex_destroy(&_lock);
    40       }
    41       void lock() {
    42         pthread_mutex_lock(&_lock);
    43       }
    44       void unlock() {
    45         pthread_mutex_unlock(&_lock);
    46       }
    47 
    48     private:
    49       pthread_mutex_t _lock;
    50     };
    51 #elif defined(LEMON_USE_WIN32_THREADS)
    52     class Lock : public WinLock {};
    53 #else
    54     class Lock {
    55     public:
    56       Lock() {}
    57       ~Lock() {}
    58       void lock() {}
    59       void unlock() {}
    60     };
    61 #endif
    62   }
    63 }
    64 
    65 #endif