Revision b781545c include/cpthreadlock.h

View differences:

include/cpthreadlock.h
12 12

  
13 13
/*--------------------------------------------------------------*
14 14
 Copyright (C) 2011 Simon Tenbusch
15
 Copyright (C) 2012 Georg Kunz
15 16

  
16 17
 This file is distributed WITHOUT ANY WARRANTY. See the file
17 18
 `license' for details on this and other legal matters.
......
20 21
#ifndef CPTHREADLOCK_H_
21 22
#define CPTHREADLOCK_H_
22 23

  
23
#include "clock.h"
24

  
25 24
#include <pthread.h>
26 25

  
27
class cPThreadLock: public cLock
26
class cPThreadLock
28 27
{
29 28
private:
30 29
    pthread_mutex_t mutex;
30

  
31 31
public:
32 32
    /**
33 33
     * Constructor.
34 34
     */
35
    cPThreadLock();
35
    cPThreadLock()
36
    {
37
        pthread_mutex_init(&mutex, NULL);
38
    }
36 39

  
37 40
    /**
38 41
     * Destructor.
39 42
     */
40
    virtual ~cPThreadLock();
43
    virtual ~cPThreadLock()
44
    {
45
        pthread_mutex_destroy(&mutex);
46
    }
41 47

  
42 48
    /*
43 49
     * Locks the lock
44 50
     */
45
    virtual void lock();
51
    inline void lock()
52
    {
53
        pthread_mutex_lock(&mutex);
54
    }
46 55

  
47 56
    /*
48 57
     * Unlocks the lock
49 58
     */
50
    virtual void unlock();
51

  
59
    inline void unlock()
60
    {
61
        pthread_mutex_unlock(&mutex);
62
    }
52 63
};
53 64

  
54 65
#endif /* CPHTREADLOCK_H_ */

Also available in: Unified diff