xref: /trunk/main/vos/source/conditn.cxx (revision ffd38472365e95f6a578737bc9a5eb0fac624a86)
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 #include <osl/time.h>
23 #include <vos/conditn.hxx>
24 #include <vos/diagnose.hxx>
25 
26 using namespace vos;
27 
28 VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OCondition, vos), VOS_NAMESPACE(OCondition, vos), VOS_NAMESPACE(OObject, vos), 0);
29 
30 // initial state of condition is not set
31 OCondition::OCondition()
32 {
33     m_Condition= osl_createCondition();
34 }
35 
36 OCondition::~OCondition()
37 {
38     osl_destroyCondition(m_Condition);
39 }
40 
41 // set condition to sal_True => wait() will not block, check() returns sal_True
42 void OCondition::set()
43 {
44     osl_setCondition(m_Condition);
45 }
46 
47 // set condition to sal_False => wait() will block, check() returns sal_False
48 void OCondition::reset()
49 {
50     osl_resetCondition(m_Condition);
51 }
52 
53 /** Blocks if condition is not set<BR>
54     If condition has been destroyed prematurely, wait() will
55     return with sal_False.
56 */
57 OCondition::TResult OCondition::wait(const TimeValue* pTimeout)
58 {
59     return (TResult)osl_waitCondition(m_Condition, pTimeout);
60 }
61 
62 /** sal_True: condition is set <BR>
63     sal_False: condition is not set <BR>
64     does not block
65 */
66 sal_Bool OCondition::check()
67 {
68     return osl_checkCondition(m_Condition);
69 }
70 
71 /* vim: set noet sw=4 ts=4: */
72