UDK 3.2.7 C/C++ API Reference
osl/conditn.hxx
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /*************************************************************************
00003  *
00004  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
00005  *
00006  * Copyright 2000, 2010 Oracle and/or its affiliates.
00007  *
00008  * OpenOffice.org - a multi-platform office productivity suite
00009  *
00010  * This file is part of OpenOffice.org.
00011  *
00012  * OpenOffice.org is free software: you can redistribute it and/or modify
00013  * it under the terms of the GNU Lesser General Public License version 3
00014  * only, as published by the Free Software Foundation.
00015  *
00016  * OpenOffice.org is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Lesser General Public License version 3 for more details
00020  * (a copy is included in the LICENSE file that accompanied this code).
00021  *
00022  * You should have received a copy of the GNU Lesser General Public License
00023  * version 3 along with OpenOffice.org.  If not, see
00024  * <http://www.openoffice.org/license.html>
00025  * for a copy of the LGPLv3 License.
00026  *
00027  ************************************************************************/
00028 
00029 #ifndef _OSL_CONDITN_HXX_
00030 #define _OSL_CONDITN_HXX_
00031 
00032 #ifdef __cplusplus
00033 
00034 #include <osl/time.h>
00035 
00036 #include <osl/conditn.h>
00037 
00038 
00039 namespace osl
00040 {
00041 
00042     class Condition
00043     {
00044     public:
00045 
00046         enum Result
00047         {
00048             result_ok      = osl_cond_result_ok,
00049             result_error   = osl_cond_result_error,
00050             result_timeout = osl_cond_result_timeout
00051         };
00052 
00053         /* Create a condition.
00054          */
00055         Condition()
00056         {
00057             condition = osl_createCondition();
00058         }
00059 
00060         /* Release the OS-structures and free condition data-structure.
00061          */
00062         ~Condition()
00063         {
00064             osl_destroyCondition(condition);
00065         }
00066 
00067         /* Release all waiting threads, check returns sal_True.
00068          */
00069         void set()
00070         {
00071             osl_setCondition(condition);
00072         }
00073 
00074         /* Reset condition to false: wait() will block, check() returns sal_False.
00075          */
00076         void reset() {
00077             osl_resetCondition(condition);
00078         }
00079 
00082         Result wait(const TimeValue *pTimeout = 0)
00083         {
00084             return (Result) osl_waitCondition(condition, pTimeout);
00085         }
00086 
00089         sal_Bool check()
00090         {
00091             return osl_checkCondition(condition);
00092         }
00093 
00094 
00095     private:
00096         oslCondition condition;
00097 
00104         Condition(const Condition&);
00105 
00112         Condition(oslCondition condition);
00113 
00117         Condition& operator= (const Condition&);
00118 
00122         Condition& operator= (oslCondition);
00123     };
00124 
00125 }
00126 
00127 #endif  /* __cplusplus */
00128 #endif  /* _OSL_CONDITN_HXX_ */
00129 
00130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines