~vanvugt/ubuntu/oneiric/mediatomb/fix-770964-784431

« back to all changes in this revision

Viewing changes to src/sync.h

  • Committer: Bazaar Package Importer
  • Author(s): Andres Mejia
  • Date: 2009-04-22 21:39:19 UTC
  • mto: (4.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20090422213919-52m015y6gcpv1m1g
Tags: upstream-0.12.0~svn2018
ImportĀ upstreamĀ versionĀ 0.12.0~svn2018

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
    Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>,
8
8
                       Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
9
9
    
10
 
    Copyright (C) 2006-2008 Gena Batyan <bgeradz@mediatomb.cc>,
 
10
    Copyright (C) 2006-2009 Gena Batyan <bgeradz@mediatomb.cc>,
11
11
                            Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
12
12
                            Leonhard Wimmer <leo@mediatomb.cc>
13
13
    
24
24
    version 2 along with MediaTomb; if not, write to the Free Software
25
25
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
26
26
    
27
 
    $Id: sync.h 1698 2008-02-23 20:48:30Z lww $
 
27
    $Id: sync.h 2010 2009-01-11 19:10:43Z lww $
28
28
*/
29
29
 
30
30
/// \file sync.h
50
50
{
51
51
public:
52
52
    
53
 
#ifndef LOG_TOMBDEBUG
 
53
#ifndef TOMBDEBUG
54
54
    inline ~MutexAutolock() { if (locked) pthread_mutex_unlock(pmutex); }
55
55
    inline void unlock() { pthread_mutex_unlock(pmutex); locked = false; }
56
56
    inline void relock() { pthread_mutex_lock(pmutex); locked = true; }
63
63
    MutexAutolock(zmm::Ref<Mutex> mutex, bool unlocked = false);
64
64
    zmm::Ref<Mutex> mutex;
65
65
    bool locked;
66
 
#ifndef LOG_TOMBDEBUG
 
66
#ifndef TOMBDEBUG
67
67
    pthread_mutex_t *pmutex;
68
68
#endif
69
69
    
75
75
public:
76
76
    Mutex(bool recursive = false);
77
77
    virtual ~Mutex();
78
 
#ifndef LOG_TOMBDEBUG
 
78
#ifndef TOMBDEBUG
79
79
    inline void lock() { pthread_mutex_lock(&mutex_struct); }
80
80
    inline void unlock() { pthread_mutex_unlock(&mutex_struct); }
81
81
#else
87
87
    pthread_mutex_t mutex_struct;
88
88
    inline pthread_mutex_t* getMutex() { return &mutex_struct; }
89
89
    
90
 
#ifdef LOG_TOMBDEBUG
 
90
#ifdef TOMBDEBUG
91
91
    void errorExit(zmm::String error);
92
92
    inline pthread_t getLockingThread() { return locking_thread; }
93
93
    void doLock(bool cond);
94
94
    void doUnlock(bool cond);
 
95
public:
95
96
    inline bool isLocked() { return lock_level > 0; }
 
97
protected:
96
98
    inline void lockAutolock() { lock(); autolock = true; }
97
99
    void unlockAutolock();
98
100
    int lock_level;
112
114
    virtual ~Cond();
113
115
    inline void signal() { pthread_cond_signal(&cond_struct); }
114
116
    inline void broadcast() { pthread_cond_broadcast(&cond_struct); }
115
 
#ifndef LOG_TOMBDEBUG
 
117
#ifndef TOMBDEBUG
116
118
    inline void wait() { pthread_cond_wait(&cond_struct, mutex->getMutex()); }
117
119
    inline int timedwait(struct timespec *timeout) { return pthread_cond_timedwait(&cond_struct, mutex->getMutex(), timeout); }
118
120
#else