/[resiprocate]/main/sip/resiprocate/os/Condition.hxx
ViewVC logotype

Contents of /main/sip/resiprocate/os/Condition.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4782 - (show annotations) (download)
Mon May 30 16:36:31 2005 UTC (14 years, 8 months ago) by sgodin
File size: 5793 byte(s)
added Boost license text
1 #if !defined(RESIP_CONDITION_HXX)
2 #define RESIP_CONDITION_HXX
3
4 #if defined(WIN32)
5 # include <windows.h>
6 # include <winbase.h>
7 #else
8 # include <pthread.h>
9 #endif
10
11 // !kh!
12 // Attempt to resolve POSIX behaviour conformance for win32 build.
13 #define RESIP_CONDITION_WIN32_CONFORMANCE_TO_POSIX
14
15 namespace resip
16 {
17
18 class Mutex;
19
20 class Condition
21 {
22 public:
23 Condition();
24 virtual ~Condition();
25
26 void wait (Mutex& mtx);
27 /** returns true if the condition was woken up by activity, false if timeout.
28 * or interrupt.
29 */
30 bool wait (Mutex& mutex, unsigned int ms);
31
32 // !kh!
33 // deprecate these?
34 void wait (Mutex* mutex);
35 bool wait (Mutex* mutex, unsigned int ms);
36
37 /** Signal one waiting thread.
38 * Returns 0, if successful, or an errorcode.
39 */
40 void signal();
41
42 /** Signal all waiting threads.
43 * Returns 0, if successful, or an errorcode.
44 */
45 void broadcast();
46
47 private:
48 // !kh!
49 // no value sematics, therefore private and not implemented.
50 Condition (const Condition&);
51 Condition& operator= (const Condition&);
52
53 private:
54 #ifdef WIN32
55 # ifdef RESIP_CONDITION_WIN32_CONFORMANCE_TO_POSIX
56 // !kh!
57 // boost clone with modification
58 // licesnse text below
59 void enterWait ();
60 void* m_gate;
61 void* m_queue;
62 void* m_mutex;
63 unsigned m_gone; // # threads that timed out and never made it to m_queue
64 unsigned long m_blocked; // # threads blocked on the condition
65 unsigned m_waiting; // # threads no longer waiting for the condition but
66 // still waiting to be removed from m_queue
67 # else
68 HANDLE mId;
69 # endif
70 #else
71 mutable pthread_cond_t mId;
72 #endif
73 };
74
75 }
76
77 #endif
78
79 // Note: Win32 Condition implementation is a modified version of the
80 // Boost.org Condition implementation
81 //
82
83 /* ====================================================================
84 *
85 * Boost Software License - Version 1.0 - August 17th, 2003
86 *
87 * Permission is hereby granted, free of charge, to any person or organization
88 * obtaining a copy of the software and accompanying documentation covered by
89 * this license (the "Software") to use, reproduce, display, distribute,
90 * execute, and transmit the Software, and to prepare derivative works of the
91 * Software, and to permit third-parties to whom the Software is furnished to
92 * do so, all subject to the following:
93 *
94 * The copyright notices in the Software and this entire statement, including
95 * the above license grant, this restriction and the following disclaimer,
96 * must be included in all copies of the Software, in whole or in part, and
97 * all derivative works of the Software, unless such copies or derivative
98 * works are solely in the form of machine-executable object code generated by
99 * a source language processor.
100 *
101 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
102 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
103 * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
104 * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
105 * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
106 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
107 * DEALINGS IN THE SOFTWARE.
108 *
109 * ====================================================================
110 */
111
112
113 /* ====================================================================
114 * The Vovida Software License, Version 1.0
115 *
116 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
117 *
118 * Redistribution and use in source and binary forms, with or without
119 * modification, are permitted provided that the following conditions
120 * are met:
121 *
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions and the following disclaimer.
124 *
125 * 2. Redistributions in binary form must reproduce the above copyright
126 * notice, this list of conditions and the following disclaimer in
127 * the documentation and/or other materials provided with the
128 * distribution.
129 *
130 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
131 * and "Vovida Open Communication Application Library (VOCAL)" must
132 * not be used to endorse or promote products derived from this
133 * software without prior written permission. For written
134 * permission, please contact vocal@vovida.org.
135 *
136 * 4. Products derived from this software may not be called "VOCAL", nor
137 * may "VOCAL" appear in their name, without prior written
138 * permission of Vovida Networks, Inc.
139 *
140 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
141 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
142 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
143 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
144 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
145 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
146 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
147 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
148 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
149 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
150 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
151 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
152 * DAMAGE.
153 *
154 * ====================================================================
155 *
156 * This software consists of voluntary contributions made by Vovida
157 * Networks, Inc. and many individuals on behalf of Vovida Networks,
158 * Inc. For more information on Vovida Networks, Inc., please see
159 * <http://www.vovida.org/>.
160 *
161 */

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27