~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.1.0/pjlib/include/pj++/lock.hpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: lock.hpp 2394 2008-12-23 17:27:53Z bennylp $  */
 
2
/* 
 
3
 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
 
4
 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 
19
 */
 
20
#ifndef __PJPP_LOCK_HPP__
 
21
#define __PJPP_LOCK_HPP__
 
22
 
 
23
#include <pj++/types.hpp>
 
24
#include <pj/lock.h>
 
25
#include <pj++/pool.hpp>
 
26
 
 
27
//////////////////////////////////////////////////////////////////////////////
 
28
// Lock object.
 
29
//
 
30
class Pj_Lock : public Pj_Object
 
31
{
 
32
public:
 
33
    //
 
34
    // Constructor.
 
35
    //
 
36
    explicit Pj_Lock(pj_lock_t *lock)
 
37
        : lock_(lock)
 
38
    {
 
39
    }
 
40
 
 
41
    //
 
42
    // Destructor.
 
43
    //
 
44
    ~Pj_Lock()
 
45
    {
 
46
        if (lock_)
 
47
            pj_lock_destroy(lock_);
 
48
    }
 
49
 
 
50
    //
 
51
    // Get pjlib compatible lock object.
 
52
    //
 
53
    pj_lock_t *pj_lock_t_()
 
54
    {
 
55
        return lock_;
 
56
    }
 
57
 
 
58
    //
 
59
    // acquire lock.
 
60
    //
 
61
    pj_status_t acquire()
 
62
    {
 
63
        return pj_lock_acquire(lock_);
 
64
    }
 
65
 
 
66
    //
 
67
    // release lock,.
 
68
    //
 
69
    pj_status_t release()
 
70
    {
 
71
        return pj_lock_release(lock_);
 
72
    }
 
73
 
 
74
protected:
 
75
    pj_lock_t *lock_;
 
76
};
 
77
 
 
78
 
 
79
//////////////////////////////////////////////////////////////////////////////
 
80
// Null lock object.
 
81
//
 
82
class Pj_Null_Lock : public Pj_Lock
 
83
{
 
84
public:
 
85
    //
 
86
    // Default constructor.
 
87
    //
 
88
    explicit Pj_Null_Lock(Pj_Pool *pool, const char *name = NULL)
 
89
        : Pj_Lock(NULL)
 
90
    {
 
91
        pj_lock_create_null_mutex(pool->pool_(), name, &lock_);
 
92
    }
 
93
};
 
94
 
 
95
//////////////////////////////////////////////////////////////////////////////
 
96
// Simple mutex lock object.
 
97
//
 
98
class Pj_Simple_Mutex_Lock : public Pj_Lock
 
99
{
 
100
public:
 
101
    //
 
102
    // Default constructor.
 
103
    //
 
104
    explicit Pj_Simple_Mutex_Lock(Pj_Pool *pool, const char *name = NULL)
 
105
        : Pj_Lock(NULL)
 
106
    {
 
107
        pj_lock_create_simple_mutex(pool->pool_(), name, &lock_);
 
108
    }
 
109
};
 
110
 
 
111
//////////////////////////////////////////////////////////////////////////////
 
112
// Recursive mutex lock object.
 
113
//
 
114
class Pj_Recursive_Mutex_Lock : public Pj_Lock
 
115
{
 
116
public:
 
117
    //
 
118
    // Default constructor.
 
119
    //
 
120
    explicit Pj_Recursive_Mutex_Lock(Pj_Pool *pool, const char *name = NULL)
 
121
        : Pj_Lock(NULL)
 
122
    {
 
123
        pj_lock_create_recursive_mutex(pool->pool_(), name, &lock_);
 
124
    }
 
125
};
 
126
 
 
127
//////////////////////////////////////////////////////////////////////////////
 
128
// Semaphore lock object.
 
129
//
 
130
class Pj_Semaphore_Lock : public Pj_Lock
 
131
{
 
132
public:
 
133
    //
 
134
    // Default constructor.
 
135
    //
 
136
    explicit Pj_Semaphore_Lock(Pj_Pool *pool, 
 
137
                               unsigned max=PJ_MAXINT32,
 
138
                               unsigned initial=0,
 
139
                               const char *name=NULL)
 
140
        : Pj_Lock(NULL)
 
141
    {
 
142
        pj_lock_create_semaphore(pool->pool_(), name, initial, max, &lock_);
 
143
    }
 
144
};
 
145
 
 
146
 
 
147
 
 
148
#endif  /* __PJPP_LOCK_HPP__ */
 
149