Back to Jetson Inference

Jetson Inference: jetson

docs/html/Thread_8h_source.html

latest7.5 KB
Original Source

| | Jetson Inference

DNN Vision Library |

Thread.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_H_

24 #define __MULTITHREAD_H_

25

26 #include <pthread.h>

27

28

35 typedef void* (*ThreadEntryFunction)( void* user_param );

36

37

44 class Thread

45 {

46 public:

50Thread();

51

55virtual ~Thread();

56

60virtual void Run();

61

66bool Start();

67

72bool Start( ThreadEntryFunction entry, void* user_param=NULL );

73

78void Stop( bool wait=false );

79

83static void InitRealtime();

84

88static int GetMaxPriority();

89

93static int GetMinPriority();

94

99static int GetPriority( pthread_t* thread=NULL );

100

105static int SetPriority( int priority, pthread_t* thread=NULL );

106

110int GetPriorityLevel();

111

115bool SetPriorityLevel( int priority );

116

121static void Yield( unsigned int ms );

122

126inline pthread_t* GetThreadID() { return &mThreadID; }

127

131bool LockAffinity( unsigned int cpu );

132

138static bool SetAffinity( unsigned int cpu, pthread_t* thread=NULL );

139

143static int GetCPU();

144

145 protected:

146

147static void* DefaultEntry( void* param );

148

149 pthread_t mThreadID;

150bool mThreadStarted;

151 };

152

153 #endif

Thread::GetPriorityLevel

int GetPriorityLevel()

Get this thread's priority level.

Thread::GetCPU

static int GetCPU()

Look up which CPU core the thread is running on.

Thread::Yield

static void Yield(unsigned int ms)

Whatever thread you are calling from, yield the processor for the specified number of milliseconds.

Thread::SetPriorityLevel

bool SetPriorityLevel(int priority)

Set this thread's priority level.

Thread::LockAffinity

bool LockAffinity(unsigned int cpu)

Lock this thread to a CPU core.

Thread::Start

bool Start()

Start the thread.

Thread::GetMinPriority

static int GetMinPriority()

Get the minimum priority level avaiable.

Thread::GetThreadID

pthread_t * GetThreadID()

Get thread identififer.

Definition: Thread.h:126

Thread::GetPriority

static int GetPriority(pthread_t *thread=NULL)

Get the priority level of the thread.

Thread::SetAffinity

static bool SetAffinity(unsigned int cpu, pthread_t *thread=NULL)

Lock the specified thread's affinity to a CPU core.

Thread::DefaultEntry

static void * DefaultEntry(void *param)

Thread::mThreadID

pthread_t mThreadID

Definition: Thread.h:149

Thread::~Thread

virtual ~Thread()

Destructor.

Thread::mThreadStarted

bool mThreadStarted

Definition: Thread.h:150

Thread::Stop

void Stop(bool wait=false)

Signal for the thread to stop running.

Thread::InitRealtime

static void InitRealtime()

Prime the system for realtime use.

Thread::GetMaxPriority

static int GetMaxPriority()

Get the maximum priority level available.

Thread::Thread

Thread()

Default constructor.

Thread

Thread class for launching an asynchronous operating-system dependent thread.

Definition: Thread.h:44

Thread::SetPriority

static int SetPriority(int priority, pthread_t *thread=NULL)

Set the priority level of the thread.

Thread::Run

virtual void Run()

User-implemented thread main() function.

ThreadEntryFunction

void *(* ThreadEntryFunction)(void *user_param)

Function pointer typedef representing a thread's main entry point.

Definition: Thread.h:35