xref: /aoo42x/main/vos/source/conditn.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <osl/time.h>
29 #include <vos/conditn.hxx>
30 #include <vos/diagnose.hxx>
31 
32 using namespace vos;
33 
34 VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OCondition, vos), VOS_NAMESPACE(OCondition, vos), VOS_NAMESPACE(OObject, vos), 0);
35 
36 /// initial state of condition is not set
37 OCondition::OCondition()
38 {
39 	m_Condition= osl_createCondition();
40 }
41 
42 OCondition::~OCondition()
43 {
44 	osl_destroyCondition(m_Condition);
45 }
46 
47 /// set condition to sal_True => wait() will not block, check() returns sal_True
48 void OCondition::set()
49 {
50 	osl_setCondition(m_Condition);
51 }
52 
53 /// set condition to sal_False => wait() will block, check() returns sal_False
54 void OCondition::reset()
55 {
56 	osl_resetCondition(m_Condition);
57 }
58 
59 /** Blocks if condition is not set<BR>
60 	If condition has been destroyed prematurely, wait() will
61 	return with sal_False.
62 */
63 OCondition::TResult OCondition::wait(const TimeValue* pTimeout)
64 {
65 	return (TResult)osl_waitCondition(m_Condition, pTimeout);
66 }
67 
68 /** sal_True: condition is set <BR>
69 	sal_False: condition is not set <BR>
70 	does not block
71 */
72 sal_Bool OCondition::check()
73 {
74 	return osl_checkCondition(m_Condition);
75 }
76 
77