update dev300-m58
[ooovba.git] / vos / source / conditn.cxx
blob4e816ed344c825f79e3add362121d19cf453063e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: conditn.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <osl/time.h>
32 #include <vos/conditn.hxx>
33 #include <vos/diagnose.hxx>
35 using namespace vos;
37 VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OCondition, vos), VOS_NAMESPACE(OCondition, vos), VOS_NAMESPACE(OObject, vos), 0);
39 /// initial state of condition is not set
40 OCondition::OCondition()
42 m_Condition= osl_createCondition();
45 OCondition::~OCondition()
47 osl_destroyCondition(m_Condition);
50 /// set condition to sal_True => wait() will not block, check() returns sal_True
51 void OCondition::set()
53 osl_setCondition(m_Condition);
56 /// set condition to sal_False => wait() will block, check() returns sal_False
57 void OCondition::reset()
59 osl_resetCondition(m_Condition);
62 /** Blocks if condition is not set<BR>
63 If condition has been destroyed prematurely, wait() will
64 return with sal_False.
66 OCondition::TResult OCondition::wait(const TimeValue* pTimeout)
68 return (TResult)osl_waitCondition(m_Condition, pTimeout);
71 /** sal_True: condition is set <BR>
72 sal_False: condition is not set <BR>
73 does not block
75 sal_Bool OCondition::check()
77 return osl_checkCondition(m_Condition);