|
||||
File indexing completed on 2025-01-18 10:04:58
0001 // Created by: Kirill Gavrilov 0002 // Copyright (c) 2018 OPEN CASCADE SAS 0003 // 0004 // This file is part of Open CASCADE Technology software library. 0005 // 0006 // This library is free software; you can redistribute it and/or modify it under 0007 // the terms of the GNU Lesser General Public License version 2.1 as published 0008 // by the Free Software Foundation, with special exception defined in the file 0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0010 // distribution for complete text of the license and disclaimer of any warranty. 0011 // 0012 // Alternatively, this file may be used under the terms of Open CASCADE 0013 // commercial license or contractual agreement. 0014 0015 #ifndef _Standard_Condition_HeaderFile 0016 #define _Standard_Condition_HeaderFile 0017 0018 #include <Standard.hxx> 0019 0020 #ifndef _WIN32 0021 #include <pthread.h> 0022 #endif 0023 0024 //! This is boolean flag intended for communication between threads. 0025 //! One thread sets this flag to TRUE to indicate some event happened 0026 //! and another thread either waits this event or checks periodically its state to perform job. 0027 //! 0028 //! This class provides interface similar to WinAPI Event objects. 0029 class Standard_Condition 0030 { 0031 public: 0032 0033 //! Default constructor. 0034 //! @param theIsSet Initial flag state 0035 Standard_EXPORT Standard_Condition (bool theIsSet); 0036 0037 //! Destructor. 0038 Standard_EXPORT ~Standard_Condition(); 0039 0040 //! Set event into signaling state. 0041 Standard_EXPORT void Set(); 0042 0043 //! Reset event (unset signaling state) 0044 Standard_EXPORT void Reset(); 0045 0046 //! Wait for Event (infinity). 0047 Standard_EXPORT void Wait(); 0048 0049 //! Wait for signal requested time. 0050 //! @param theTimeMilliseconds wait limit in milliseconds 0051 //! @return true if get event 0052 Standard_EXPORT bool Wait (int theTimeMilliseconds); 0053 0054 //! Do not wait for signal - just test it state. 0055 //! @return true if get event 0056 Standard_EXPORT bool Check(); 0057 0058 //! Method perform two steps at-once - reset the event object 0059 //! and returns true if it was in signaling state. 0060 //! @return true if event object was in signaling state. 0061 Standard_EXPORT bool CheckReset(); 0062 0063 #ifdef _WIN32 0064 //! Access native HANDLE to Event object. 0065 void* getHandle() const { return myEvent; } 0066 #endif 0067 0068 private: 0069 //! This method should not be called (prohibited). 0070 Standard_Condition (const Standard_Condition& theCopy); 0071 //! This method should not be called (prohibited). 0072 Standard_Condition& operator= (const Standard_Condition& theCopy); 0073 0074 private: 0075 0076 #ifdef _WIN32 0077 void* myEvent; 0078 #else 0079 pthread_mutex_t myMutex; 0080 pthread_cond_t myCond; 0081 bool myFlag; 0082 #endif 0083 0084 }; 0085 0086 #endif // _Standard_Condition_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |