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