Jetson Inference
DNN Vision Library
Event.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef __MULTITHREAD_EVENT_H_
24 #define __MULTITHREAD_EVENT_H_
25 
26 #include "Mutex.h"
27 #include "timespec.h"
28 
33 class Event
34 {
35 public:
40  inline Event( bool auto_reset=true );
41 
45  inline ~Event();
46 
50  inline void Wake();
51 
55  inline void Reset();
56 
61  inline bool Query();
62 
67  inline bool Wait();
68 
73  inline bool Wait( const timespec& timeout );
74 
79  inline bool Wait( uint64_t timeout );
80 
85  inline bool WaitNs( uint64_t timeout );
86 
91  inline bool WaitUs( uint64_t timeout );
92 
96  inline pthread_cond_t* GetID();
97 
98 protected:
99 
100  pthread_cond_t mID;
101 
103  bool mQuery;
105 };
106 
107 // inline implementations
108 #include "Event.inl"
109 
110 #endif
Event::Wait
bool Wait()
Wait until this event is raised.
Event
Event object for signalling other threads.
Definition: Event.h:33
Event::Query
bool Query()
Query the status of this event.
Event::WaitNs
bool WaitNs(uint64_t timeout)
Wait for a specified number of nanoseconds until this event is raised or timeout occurs.
Mutex
A lightweight mutual exclusion lock.
Definition: Mutex.h:35
Event::mID
pthread_cond_t mID
Definition: Event.h:100
Event::Wake
void Wake()
Raise the event.
Event::mAutoReset
bool mAutoReset
Definition: Event.h:104
Event::Reset
void Reset()
Reset the event status to un-raised.
Event::Event
Event(bool auto_reset=true)
Event constructor.
Mutex.h
Event::mQueryMutex
Mutex mQueryMutex
Definition: Event.h:102
Event::WaitUs
bool WaitUs(uint64_t timeout)
Wait for a specified number of microseconds until this event is raised or timeout occurs.
Event::GetID
pthread_cond_t * GetID()
Get the Event object.
Event::~Event
~Event()
Destructor.
Event::mQuery
bool mQuery
Definition: Event.h:103
timespec.h