LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/osl - conditn.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 16 16 100.0 %
Date: 2012-12-27 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef _OSL_CONDITN_HXX_
      21             : #define _OSL_CONDITN_HXX_
      22             : 
      23             : #ifdef __cplusplus
      24             : 
      25             : #include <osl/time.h>
      26             : 
      27             : #include <osl/conditn.h>
      28             : 
      29             : 
      30             : namespace osl
      31             : {
      32             : 
      33             :     class Condition
      34             :     {
      35             :     public:
      36             : 
      37             :         enum Result
      38             :         {
      39             :             result_ok      = osl_cond_result_ok,
      40             :             result_error   = osl_cond_result_error,
      41             :             result_timeout = osl_cond_result_timeout
      42             :         };
      43             : 
      44             :         /* Create a condition.
      45             :          */
      46       11364 :         Condition()
      47             :         {
      48       11364 :             condition = osl_createCondition();
      49       11364 :         }
      50             : 
      51             :         /* Release the OS-structures and free condition data-structure.
      52             :          */
      53       10290 :         ~Condition()
      54             :         {
      55       10290 :             osl_destroyCondition(condition);
      56       10290 :         }
      57             : 
      58             :         /* Release all waiting threads, check returns sal_True.
      59             :          */
      60       77128 :         void set()
      61             :         {
      62       77128 :             osl_setCondition(condition);
      63       77128 :         }
      64             : 
      65             :         /* Reset condition to false: wait() will block, check() returns sal_False.
      66             :          */
      67       64317 :         void reset() {
      68       64317 :             osl_resetCondition(condition);
      69       64317 :         }
      70             : 
      71             :         /** Blocks the calling thread until condition is set.
      72             :          */
      73       30225 :         Result wait(const TimeValue *pTimeout = 0)
      74             :         {
      75       30225 :             return (Result) osl_waitCondition(condition, pTimeout);
      76             :         }
      77             : 
      78             :         /** Checks if the condition is set without blocking.
      79             :          */
      80      118349 :         sal_Bool check()
      81             :         {
      82      118349 :             return osl_checkCondition(condition);
      83             :         }
      84             : 
      85             : 
      86             :     private:
      87             :         oslCondition condition;
      88             : 
      89             :         /** The underlying oslCondition has no reference count.
      90             : 
      91             :         Since the underlying oslCondition is not a reference counted object, copy
      92             :         constructed Condition may work on an already destructed oslCondition object.
      93             : 
      94             :         */
      95             :         Condition(const Condition&);
      96             : 
      97             :         /** The underlying oslCondition has no reference count.
      98             : 
      99             :         When destructed, the Condition object destroys the undelying oslCondition,
     100             :         which might cause severe problems in case it's a temporary object.
     101             : 
     102             :         */
     103             :         Condition(oslCondition condition);
     104             : 
     105             :         /** This assignment operator is private for the same reason as
     106             :             the copy constructor.
     107             :         */
     108             :         Condition& operator= (const Condition&);
     109             : 
     110             :         /** This assignment operator is private for the same reason as
     111             :             the constructor taking a oslCondition argument.
     112             :         */
     113             :         Condition& operator= (oslCondition);
     114             :     };
     115             : 
     116             : }
     117             : 
     118             : #endif  /* __cplusplus */
     119             : #endif  /* _OSL_CONDITN_HXX_ */
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10