1 // Created by: Kirill Gavrilov
2 // Copyright (c) 2018 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _Standard_Condition_HeaderFile
16 #define _Standard_Condition_HeaderFile
18 #include <Standard.hxx>
24 //! This is boolean flag intended for communication between threads.
25 //! One thread sets this flag to TRUE to indicate some event happened
26 //! and another thread either waits this event or checks periodically its state to perform job.
28 //! This class provides interface similar to WinAPI Event objects.
29 class Standard_Condition
33 //! Default constructor.
34 //! @param theIsSet Initial flag state
35 Standard_EXPORT Standard_Condition (bool theIsSet);
38 Standard_EXPORT ~Standard_Condition();
40 //! Set event into signaling state.
41 Standard_EXPORT void Set();
43 //! Reset event (unset signaling state)
44 Standard_EXPORT void Reset();
46 //! Wait for Event (infinity).
47 Standard_EXPORT void Wait();
49 //! Wait for signal requested time.
50 //! @param theTimeMilliseconds wait limit in milliseconds
51 //! @return true if get event
52 Standard_EXPORT bool Wait (int theTimeMilliseconds);
54 //! Do not wait for signal - just test it state.
55 //! @return true if get event
56 Standard_EXPORT bool Check();
58 //! Method perform two steps at-once - reset the event object
59 //! and returns true if it was in signaling state.
60 //! @return true if event object was in signaling state.
61 Standard_EXPORT bool CheckReset();
64 //! Access native HANDLE to Event object.
65 void* getHandle() const { return myEvent; }
69 //! This method should not be called (prohibited).
70 Standard_Condition (const Standard_Condition& theCopy);
71 //! This method should not be called (prohibited).
72 Standard_Condition& operator= (const Standard_Condition& theCopy);
79 pthread_mutex_t myMutex;
80 pthread_cond_t myCond;
86 #endif // _Standard_Condition_HeaderFile