xref: /trunk/main/vos/source/conditn.cxx (revision e8c8fa4b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include <osl/time.h>
25 #include <vos/conditn.hxx>
26 #include <vos/diagnose.hxx>
27 
28 using namespace vos;
29 
30 VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OCondition, vos), VOS_NAMESPACE(OCondition, vos), VOS_NAMESPACE(OObject, vos), 0);
31 
32 /// initial state of condition is not set
OCondition()33 OCondition::OCondition()
34 {
35 	m_Condition= osl_createCondition();
36 }
37 
~OCondition()38 OCondition::~OCondition()
39 {
40 	osl_destroyCondition(m_Condition);
41 }
42 
43 /// set condition to sal_True => wait() will not block, check() returns sal_True
set()44 void OCondition::set()
45 {
46 	osl_setCondition(m_Condition);
47 }
48 
49 /// set condition to sal_False => wait() will block, check() returns sal_False
reset()50 void OCondition::reset()
51 {
52 	osl_resetCondition(m_Condition);
53 }
54 
55 /** Blocks if condition is not set<BR>
56 	If condition has been destroyed prematurely, wait() will
57 	return with sal_False.
58 */
wait(const TimeValue * pTimeout)59 OCondition::TResult OCondition::wait(const TimeValue* pTimeout)
60 {
61 	return (TResult)osl_waitCondition(m_Condition, pTimeout);
62 }
63 
64 /** sal_True: condition is set <BR>
65 	sal_False: condition is not set <BR>
66 	does not block
67 */
check()68 sal_Bool OCondition::check()
69 {
70 	return osl_checkCondition(m_Condition);
71 }
72 
73