AJA NTV2 SDK  17.0.1.1246
NTV2 SDK 17.0.1.1246
threadimpl.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #include "ajabase/system/debug.h"
9 #include <errno.h>
10 #include <sched.h>
11 #include <signal.h>
12 #include <sys/time.h>
13 #include <sys/resource.h>
14 //#include <sys/syscall.h>
15 //#include <sys/prctl.h>
16 #include <unistd.h>
17 #include <string.h>
18 
19 static const size_t STACK_SIZE = 1024 * 1024;
20 
21 bool is_pthread_alive(pthread_t thread)
22 {
23 #if 0
24 #if 1
25  // since this is a Linux impl use the non portable, non blocking pthread_tryjoin_np.
26  // If the thread is alive a non zero value is returned
27  // NOTE: if this impl is ever changed to not be PTHREAD_CREATE_JOINABLE this will not work
28  void* exitValue;
29  if (pthread_tryjoin_np(thread, &exitValue) != 0)
30  return true;
31 #else
32  // This way no longer works with modern glibc
33  // seen failures with versions: 2.34 & 2.35
34  // seen success with versions: 2.31 and earlier
35  //
36  // with zero, no signal sent to thread, it's only checked for validity
37  if (!pthread_kill(thread, 0))
38  return true;
39 #endif
40 #endif
41 
42  return false;
43 }
44 
46  mpThreadContext(pThreadContext),
47  mThread(0),
48  mTid(0),
49  mPriority(AJA_ThreadPriority_Normal),
50  mThreadFunc(0),
51  mpUserContext(0),
52  mThreadStarted(false),
53  mTerminate(false),
54  mExiting(false)
55 {
56 #if 0
57  int rc = pthread_mutex_init(&mStartMutex, 0);
58  if (rc)
59  {
60  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThreadImpl(%p) start mutex init reported error %d", mpThreadContext, rc);
61  }
62 
63  rc = pthread_cond_init(&mStartCond, 0);
64  if (rc)
65  {
66  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThreadImpl(%p) start cond init reported error %d", mpThreadContext, rc);
67  }
68 
69  rc = pthread_mutex_init(&mExitMutex, 0);
70  if (rc)
71  {
72  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThreadImpl(%p) exit mutex init reported error %d", mpThreadContext, rc);
73  }
74 
75  rc = pthread_cond_init(&mExitCond, 0);
76  if (rc)
77  {
78  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThreadImpl(%p) exit cond init reported error %d", mpThreadContext, rc);
79  }
80 #endif
81 }
82 
83 
85 {
86  Stop();
87 
88 #if 0
89  int rc = pthread_mutex_destroy(&mStartMutex);
90  if (rc)
91  {
92  AJA_REPORT(0, AJA_DebugSeverity_Error, "~AJAThreadImpl(%p) start mutex destroy reported error %d", mpThreadContext, rc);
93  }
94 
95  rc = pthread_cond_destroy(&mStartCond);
96  if (rc)
97  {
98  AJA_REPORT(0, AJA_DebugSeverity_Error, "~AJAThreadImpl(%p) start cond destroy reported error %d", mpThreadContext, rc);
99  }
100 
101  rc = pthread_mutex_destroy(&mExitMutex);
102  if (rc)
103  {
104  AJA_REPORT(0, AJA_DebugSeverity_Error, "~AJAThreadImpl(%p) exit mutex destroy reported error %d", mpThreadContext, rc);
105  }
106 
107  rc = pthread_cond_destroy(&mExitCond);
108  if (rc)
109  {
110  AJA_REPORT(0, AJA_DebugSeverity_Error, "~AJAThreadImpl(%p) exit cond destroy reported error %d", mpThreadContext, rc);
111  }
112 #endif
113 }
114 
115 AJAStatus
117 {
118 #if 0
119  AJAAutoLock lock(&mLock);
120 
121  // return success if thread is already running
122  if (Active())
123  {
124  return AJA_STATUS_SUCCESS;
125  }
126 
127  // Windows version currently uses the default stack size
128  // The docs say this is 1MB, so give our threads the same stack size
129  pthread_attr_t attr;
130  int rc = 0;
131  rc |= pthread_attr_init(&attr);
132  rc |= pthread_attr_setstacksize(&attr, STACK_SIZE);
133  rc |= pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
134  if (rc)
135  {
136  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThreadImpl::Start(%p) error setting thread attributes", mpThreadContext);
137  mThread = 0;
138  return AJA_STATUS_FAIL;
139  }
140 
141  mTerminate = false;
142  mExiting = false;
143 
144  // we're going to create the thread, then block until it tells us it's alive
145  rc = pthread_mutex_lock(&mStartMutex);
146  if (rc)
147  {
148  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThreadImpl::Start(%p) error %d locking start mutex", mpThreadContext, rc);
149  return AJA_STATUS_FAIL;
150  }
151 
152  // create the thread
153  mThreadStarted = false;
154 
155  rc = pthread_create(&mThread, &attr, ThreadProcStatic, this);
156  if (rc)
157  {
158  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThreadImpl::Start(%p) error %d creating thread", mpThreadContext, rc);
159  mThread = 0;
160  return AJA_STATUS_FAIL;
161  }
162 
163  // wait until the new thread signals us that it's alive (and has logged its thread ID)
164  // ToDo: add a timeout? how do we respond if the thread DOESN'T come up?
165  AJAStatus status = AJA_STATUS_SUCCESS;
166 
167  while (!mThreadStarted)
168  {
169  rc = pthread_cond_wait(&mStartCond, &mStartMutex);
170 
171  if (rc)
172  {
173  status = AJA_STATUS_FAIL;
175  "AJAThread(%p)::Start pthread_cond_wait returned error %d",
176  mpThreadContext, rc);
177  break;
178  }
179  }
180 
181  rc = pthread_mutex_unlock(&mStartMutex);
182  if (rc)
183  {
184  status = AJA_STATUS_FAIL;
186  "AJAThread(%p)::Start error %d unlocking start mutex",
187  mpThreadContext, rc);
188  }
189 
190 
191 #if 0 // This should be set within the running thread itself if a dynamic change
192  // in priority is desired. This will fail in a daemon invocation.
193 
194  // Now that the new thread is up and running and has reported its
195  // thread ID, set the thread priority
196  if ( AJA_SUCCESS(status) )
197  status = SetPriority(mPriority);
198 #endif
199 
200  return status;
201 #else
202  return AJA_STATUS_FAIL;
203 #endif
204 }
205 
206 
207 AJAStatus
208 AJAThreadImpl::Stop(uint32_t timeout)
209 {
210 #if 0
211  AJAAutoLock lock(&mLock);
212  AJAStatus returnStatus = AJA_STATUS_SUCCESS;
213 
214  // return success if the thread is already stopped
215  if (!Active())
216  {
217  return AJA_STATUS_SUCCESS;
218  }
219 
220  // wait for thread to stop
221  int rc = pthread_mutex_lock(&mExitMutex);
222  if (rc)
223  {
224  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThreadImpl::Stop(%p) error %d locking exit mutex", mpThreadContext, rc);
225  return AJA_STATUS_FAIL;
226  }
227 
228  // calculate how long to wait
229  struct timespec ts;
231 
232  if (timeout == 0xffffffff)
233  {
234  ts.tv_sec += 60 * 60 * 24 * 365; // A year is infinite enough
235  }
236  else
237  {
238  // Calculates the non-second portion of the timeout
239  // to nanoseconds.
240  uint32_t nsec = ((timeout % 1000) * 1000000);
241 
242  // Add the current nanosecond count to the result
243  nsec += ts.tv_nsec;
244 
245  struct timespec ts1;
246  ts1 = ts;
247 
248  // The addition of the two nanosecond values may wrap to
249  // another second, so note that; but our nsec portion will
250  // always be less than a second. Finally, create the
251  // absolute time during which the timeout will lapse.
252  ts.tv_sec += (timeout / 1000) + (nsec / 1000000000);
253  ts.tv_nsec = (nsec % 1000000000);
254  }
255 
256  // signal thread to stop
257  mTerminate = true;
258 
259  // loop until signaled or timed out
260  do
261  {
262  if (mExiting == false)
263  {
264  rc = pthread_cond_timedwait(&mExitCond, &mExitMutex, &ts);
265  if (rc)
266  {
267  returnStatus = AJA_STATUS_FAIL;
268  AJA_REPORT(
269  0,
271  "AJAThread(%p)::Stop pthread_cond_timedwait returned error %d",
272  mpThreadContext, rc);
273 
274  // non-timeout errors release the mutex by themselves
275  if (rc == ETIMEDOUT)
276  {
277  rc = pthread_mutex_unlock(&mExitMutex);
278  if (rc)
279  {
280  AJA_REPORT(
281  0,
283  "AJAThread(%p)::Stop error %d unlocking timeout mutex",
284  mpThreadContext, rc);
285  }
286  }
287  break;
288  }
289  }
290 
291  // deal with spurious wakeups here
292  if (!mExiting)
293  continue; // the thread hasn't left its loop, so wait some more
294  else
295  {
296  rc = pthread_mutex_unlock(&mExitMutex);
297  if (rc)
298  {
299  returnStatus = AJA_STATUS_FAIL;
300  AJA_REPORT(
301  0,
303  "AJAThread(%p)::Stop error %d unlocking exit mutex",
304  mpThreadContext, rc);
305  }
306  break;
307  }
308  } while (rc == 0);
309 
310 
311  // close thread handle
312  void* exitValue;
313  rc = pthread_join(mThread, &exitValue);
314  if( rc )
315  {
316  returnStatus = AJA_STATUS_FAIL;
317  AJA_REPORT(
318  0,
320  "AJAThread(%p)::Stop error %d from pthread_join",
321  mpThreadContext, rc);
322  }
323  mThread = 0;
324 
325  return returnStatus;
326 #else
327  return AJA_STATUS_FAIL;
328 #endif
329 }
330 
331 AJAStatus
332 AJAThreadImpl::Kill(uint32_t exitCode)
333 {
334  AJA_UNUSED(exitCode);
335 
336 #if 0
337  AJAAutoLock lock(&mLock);
338  AJAStatus returnStatus = AJA_STATUS_SUCCESS;
339 
340  // If the thread doesn't exist, consider the Kill successful
342  return returnStatus;
343 
344  // Try to make the thread as killable as possible
345  int rc = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
346  if( rc )
347  {
348  returnStatus = AJA_STATUS_FAIL;
349  AJA_REPORT(
350  0,
352  "AJAThread(%p)::Kill error %d from pthread_setcancelstate",
353  mpThreadContext, rc);
354  }
355  rc = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
356  if( rc )
357  {
358  returnStatus = AJA_STATUS_FAIL;
359  AJA_REPORT(
360  0,
362  "AJAThread(%p)::Kill error %d from pthread_setcanceltype",
363  mpThreadContext, rc);
364  }
365 
366  // This should kill the thread, but there are no guarantees
367  rc = pthread_cancel(mThread);
368  if( rc )
369  {
370  returnStatus = AJA_STATUS_FAIL;
371  AJA_REPORT(
372  0,
374  "AJAThread(%p)::Kill error %d from pthread_cancel",
375  mpThreadContext, rc);
376  }
377 
378  return returnStatus;
379 #else
380  return AJA_STATUS_FAIL;
381 #endif
382 }
383 
384 
385 bool
387 {
388 #if 0
389  // if no handle thread is not active
390  if (mThread == 0)
391  {
392  return false;
393  }
394 
396  return true;
397 
398  // the thread has terminated, so clear the handle
399  mThread = 0;
400 #endif
401 
402  return false;
403 }
404 
405 bool
407 {
408 #if 0
409  if(mThread == 0)
410  {
411  return false;
412  }
413 
414  if( pthread_equal(mThread, pthread_self()) )
415  {
416  return true;
417  }
418 #endif
419 
420  return false;
421 }
422 
423 
424 AJAStatus
426 {
427 #if 0
428  AJAAutoLock lock(&mLock);
429 
430  // save priority for starts
431  mPriority = threadPriority;
432 
433  // If thread isn't running, we're done (but we've logged the desired priority for later)
434  if (!Active())
435  return AJA_STATUS_SUCCESS;
436 
437  // If we haven't been able to get a thread ID (thread not running yet?), bail
438  if (mTid == 0) // note: we're assuming PID == 0 never happens in nature...?
439  return AJA_STATUS_FAIL;
440 
441 
442  // If thread is already running, tweak its priority
443  // We're going to mix Realtime priorities (policy == SCHED_FIFO/SCHED_RR) and "standard" round-robin priorities
444  // (policy == SCHED_OTHER) in one API...
445  bool bRTPriority = false; //
446  int newPriority = 0; // "nice" priority used by setpriority() when bRTPriority = false, or RT priority used by sched_setscheduler() when bRTPriority = true
447 
448  switch (threadPriority)
449  {
451  bRTPriority = false; // use setpriority()
452  newPriority = 0; // -20 to +19, standard "nice" priority
453  break;
455  bRTPriority = false; // use setpriority()
456  newPriority = 10; // positive "nice" values have LOWER priority
457  break;
459  bRTPriority = false; // use setpriority()
460  newPriority = -10; // negative "nice" values have HIGHER priority
461  break;
463  bRTPriority = false; // use setpriority()
464  newPriority = -5; // negative "nice" values have HIGHER priority
465  break;
467  bRTPriority = true; // use sched_setscheduler()
468  newPriority = 90; // 1 - 99 (higher values = higher priority)
469  break;
471  default:
472  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThread(%p)::SetPriority: bad thread priority %d", mpThreadContext, threadPriority);
473  return AJA_STATUS_RANGE;
474  }
475 
476  // first, set (or unset) the RT priority
477  struct sched_param newParam;
478  newParam.sched_priority = (bRTPriority ? newPriority : 0); // if we're not using RT Priority, reset to SCHED_OTHER and sched_priority = 0
479  int newPolicy = (bRTPriority ? SCHED_RR : SCHED_OTHER);
480  int rc = pthread_setschedparam(mThread, newPolicy, &newParam);
481  if (rc != 0)
482  {
483  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThread(%p)::SetPriority: error %d setting sched param: policy = %d, priority = %d\n", mpThreadContext, rc, newPolicy, newParam.sched_priority);
484  return AJA_STATUS_FAIL;
485  }
486 
487  // now set the standard ("nice") priority
488  int newNice = (bRTPriority ? 0 : newPriority); // if we're using RT Priority (SCHED_RR or SCHED_FF), reset "nice" level to zero
489  rc = setpriority(PRIO_PROCESS, mTid, newNice);
490  if (errno != 0)
491  {
492  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThread(%p)::SetPriority: error %d setting nice level: %d\n", mpThreadContext, rc, newNice);
493  return AJA_STATUS_FAIL;
494  }
495 
496  return AJA_STATUS_SUCCESS;
497 #else
498  return AJA_STATUS_FAIL;
499 #endif
500 }
501 
502 
503 AJAStatus
505 {
506 #if 0
507  if (pThreadPriority == NULL)
508  {
509  return AJA_STATUS_INITIALIZE;
510  }
511 
512  *pThreadPriority = mPriority;
513 
514  return AJA_STATUS_SUCCESS;
515 #else
516  return AJA_STATUS_FAIL;
517 #endif
518 }
519 
520 
521 AJAStatus
523 {
524 #if 0
525  int pval = 0;
526  switch(policy)
527  {
529  pval = SCHED_FIFO;
530  break;
532  pval = SCHED_RR;
533  break;
534  default:
535  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThread(%p)::SetRealTime: bad thread policy %d", mpThreadContext, policy);
536  return AJA_STATUS_RANGE;
537  }
538 
539  for(int i = 0; i < 30; i++)
540  {
541  if(!Active())
542  {
543  usleep(1000);
544  continue;
545  }
546  struct sched_param newParam;
547  memset(&newParam, 0, sizeof(newParam));
548  newParam.sched_priority = priority;
549  int rc = pthread_setschedparam(mThread, pval, &newParam);
550  if (rc != 0)
551  {
552  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThread(%p)::SetRealTime: error %d setting sched param: policy = %d, priority = %d\n", mpThreadContext, rc, pval, newParam.sched_priority);
553  return AJA_STATUS_FAIL;
554  }
555  return AJA_STATUS_SUCCESS;
556  }
557  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThread(%p)::SetRealTime: Failed to set realtime thread is not running\n", mpThreadContext);
558  return AJA_STATUS_FAIL;
559 #else
560  return AJA_STATUS_FAIL;
561 #endif
562 }
563 
564 
565 AJAStatus
566 AJAThreadImpl::Attach(AJAThreadFunction* pThreadFunction, void* pUserContext)
567 {
568 #if 0
569  // remember the users thread function
570  mThreadFunc = pThreadFunction;
571  mpUserContext = pUserContext;
572 
573  return AJA_STATUS_SUCCESS;
574 #else
575  return AJA_STATUS_FAIL;
576 #endif
577 }
578 
579 
580 void*
581 AJAThreadImpl::ThreadProcStatic(void* pThreadImplContext)
582 {
583 #if 0
584  // this function is called when the thread starts
585  AJAThreadImpl* pThreadImpl = static_cast<AJAThreadImpl*>(pThreadImplContext);
586  AJA_ASSERT(pThreadImpl != NULL);
587  if (pThreadImpl == NULL)
588  {
589  return (void*)0;
590  }
591 
592  // Who am I? We need the thread ID (TID) in order to set thread scheduler priorities
593 // pid_t myTid = gettid(); // in theory we could make this call, but Glibc doesn't support it
594  errno = 0; // so instead we do this (ick...)
595  pid_t myTid = syscall( SYS_gettid );
596  if (errno == 0) // theoretically gettid() cannot fail, so by extension syscall(SYS_gettid) can't either...?
597  pThreadImpl->mTid = myTid;
598 
599 
600  // signal parent we've started
601  int rc = pthread_mutex_lock(&pThreadImpl->mStartMutex);
602  if (rc)
603  {
604  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThread(%p)::ThreadProcStatic error %d locking start mutex", pThreadImpl->mpThreadContext, rc);
605  return (void*)0;
606  }
607 
608  pThreadImpl->mThreadStarted = true;
609 
610  rc = pthread_cond_signal(&pThreadImpl->mStartCond);
611  if (rc)
612  {
613  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThread(%p)::ThreadProcStatic error %d signaling start cond variable", pThreadImpl->mpThreadContext, rc);
614  return (void*)0;
615  }
616  rc = pthread_mutex_unlock(&pThreadImpl->mStartMutex);
617  if (rc)
618  {
619  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThread(%p)::ThreadProcStatic error %d unlocking start mutex", pThreadImpl->mpThreadContext, rc);
620  return (void*)0;
621  }
622 
623 
624  // call the thread worker function
625  try
626  {
627  // if user specified function call it
628  if (pThreadImpl->mThreadFunc != NULL)
629  {
630  (*pThreadImpl->mThreadFunc)(pThreadImpl->mpThreadContext, pThreadImpl->mpUserContext);
631  }
632  // otherwise call the virtual function
633  else
634  {
635  pThreadImpl->mpThreadContext->ThreadRun();
636  }
637  }
638  catch(...)
639  {
640  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThread(%p)::ThreadProcStatic exception in thread function", pThreadImpl->mpThreadContext);
641  return (void*)0;
642  }
643 
644  // signal parent we're exiting
645  pThreadImpl->mExiting = true;
646 
647  rc = pthread_mutex_lock(&pThreadImpl->mExitMutex);
648  if (rc)
649  {
650  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThread(%p)::ThreadProcStatic error %d locking exit mutex", pThreadImpl->mpThreadContext, rc);
651  return (void*)0;
652  }
653  rc = pthread_cond_signal(&pThreadImpl->mExitCond);
654  if (rc)
655  {
656  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThread(%p)::ThreadProcStatic error %d signaling cond variable", pThreadImpl->mpThreadContext, rc);
657  return (void*)0;
658  }
659  rc = pthread_mutex_unlock(&pThreadImpl->mExitMutex);
660  if (rc)
661  {
662  AJA_REPORT(0, AJA_DebugSeverity_Error, "AJAThread(%p)::ThreadProcStatic error %d unlocking exit mutex", pThreadImpl->mpThreadContext, rc);
663  return (void*)0;
664  }
665 
666  return (void*)1;
667 #else
668  return (void *)0;
669 #endif
670 }
671 
673 #if 0
674  int ret = prctl(PR_SET_NAME, (unsigned long)name, 0, 0);
675  if(ret == -1) {
676  AJA_REPORT(0, AJA_DebugSeverity_Error, "Failed to set thread name to %s", name);
677  return AJA_STATUS_FAIL;
678  }
679  return AJA_STATUS_SUCCESS;
680 #else
681  return AJA_STATUS_FAIL;
682 #endif
683 }
684 
686 {
687 #if 0
688  errno = 0;
689  pid_t tid = syscall(SYS_gettid);
690  if (errno == 0)
691  return uint64_t(tid);
692  else
693 #endif
694  return 0;
695 }
AJAThreadImpl::IsCurrentThread
bool IsCurrentThread()
Definition: threadimpl.cpp:406
AJA_ThreadPriority_High
@ AJA_ThreadPriority_High
Definition: thread.h:44
AJAThreadImpl::mPriority
AJAThreadPriority mPriority
Definition: threadimpl.h:49
NULL
#define NULL
Definition: ntv2caption608types.h:19
AJAThreadImpl::mpUserContext
void * mpUserContext
Definition: threadimpl.h:51
AJA_STATUS_SUCCESS
@ AJA_STATUS_SUCCESS
Definition: types.h:368
AJAThreadImpl::GetThreadId
static uint64_t GetThreadId()
Definition: threadimpl.cpp:685
AJAThreadImpl::SetThreadName
AJAStatus SetThreadName(const char *name)
Definition: threadimpl.cpp:672
AJA_DebugSeverity_Error
@ AJA_DebugSeverity_Error
Definition: debugshare.h:28
AJAThreadImpl::mThreadFunc
AJAThreadFunction * mThreadFunc
Definition: threadimpl.h:50
AJAThreadImpl::~AJAThreadImpl
virtual ~AJAThreadImpl()
Definition: threadimpl.cpp:84
AJAThreadImpl::mThread
pthread_t mThread
Definition: threadimpl.h:47
AJAThreadPriority
AJAThreadPriority
Definition: thread.h:39
AJA_UNUSED
#define AJA_UNUSED(_x_)
Definition: types.h:411
AJAThreadImpl
Definition: threadimpl.h:18
AJA_ThreadPriority_TimeCritical
@ AJA_ThreadPriority_TimeCritical
Definition: thread.h:45
AJA_ThreadRealTimePolicyFIFO
@ AJA_ThreadRealTimePolicyFIFO
Definition: thread.h:52
AJAThread
Definition: thread.h:69
AJAThreadImpl::mLock
AJALock mLock
Definition: threadimpl.h:52
AJA_ThreadRealTimePolicyRoundRobin
@ AJA_ThreadRealTimePolicyRoundRobin
Definition: thread.h:53
AJAStatus
AJAStatus
Definition: types.h:365
AJA_ThreadPriority_Unknown
@ AJA_ThreadPriority_Unknown
Definition: thread.h:41
CLOCK_REALTIME
#define CLOCK_REALTIME
Definition: pthreadsextra.h:21
AJAThreadImpl::Kill
AJAStatus Kill(uint32_t exitCode)
Definition: threadimpl.cpp:332
AJAThreadImpl::mExitCond
pthread_cond_t mExitCond
Definition: threadimpl.h:61
threadimpl.h
Declares the AJAThreadImpl class.
AJA_STATUS_FAIL
@ AJA_STATUS_FAIL
Definition: types.h:369
AJA_ThreadPriority_Normal
@ AJA_ThreadPriority_Normal
Definition: thread.h:43
AJA_SUCCESS
#define AJA_SUCCESS(_status_)
Definition: types.h:357
AJA_REPORT
#define AJA_REPORT(_index_, _severity_, _format_,...)
Definition: debug.h:117
AJAThread::ThreadRun
virtual AJAStatus ThreadRun()
Definition: thread.cpp:38
AJAThreadImpl::mTid
pid_t mTid
Definition: threadimpl.h:48
AJAThreadImpl::mStartCond
pthread_cond_t mStartCond
Definition: threadimpl.h:56
AJAThreadImpl::Active
bool Active()
Definition: threadimpl.cpp:386
AJAThreadImpl::mStartMutex
pthread_mutex_t mStartMutex
Definition: threadimpl.h:55
AJA_STATUS_RANGE
@ AJA_STATUS_RANGE
Definition: types.h:372
AJAAutoLock
Definition: lock.h:91
AJA_STATUS_INITIALIZE
@ AJA_STATUS_INITIALIZE
Definition: types.h:373
AJAThreadImpl::mTerminate
bool mTerminate
Definition: threadimpl.h:58
false
#define false
Definition: ntv2devicefeatures.h:25
AJA_ThreadPriority_AboveNormal
@ AJA_ThreadPriority_AboveNormal
Definition: thread.h:46
AJAThreadImpl::mThreadStarted
bool mThreadStarted
Definition: threadimpl.h:54
AJAThreadRealTimePolicy
AJAThreadRealTimePolicy
Definition: thread.h:50
AJAThreadImpl::mExitMutex
pthread_mutex_t mExitMutex
Definition: threadimpl.h:60
AJA_ThreadPriority_Low
@ AJA_ThreadPriority_Low
Definition: thread.h:42
AJAThreadImpl::ThreadProcStatic
static void * ThreadProcStatic(void *pThreadImplContext)
Definition: threadimpl.cpp:581
AJAThreadImpl::AJAThreadImpl
AJAThreadImpl(AJAThread *pThreadContext)
Definition: threadimpl.cpp:45
AJAThreadImpl::Stop
AJAStatus Stop(uint32_t timeout=0xffffffff)
Definition: threadimpl.cpp:208
AJAThread::AJAThreadFunction
void AJAThreadFunction(AJAThread *pThread, void *pContext)
Definition: thread.h:22
AJAThreadImpl::mpThreadContext
AJAThread * mpThreadContext
Definition: threadimpl.h:46
AJA_ASSERT
#define AJA_ASSERT(_expression_)
Definition: debug.h:113
AJAThreadImpl::Start
AJAStatus Start()
Definition: threadimpl.cpp:116
is_pthread_alive
bool is_pthread_alive(pthread_t thread)
Definition: threadimpl.cpp:21
clock_gettime
int clock_gettime(clockid_t clk_id, struct timespec *tp)
Definition: pthreadsextra.cpp:12
AJAThreadImpl::SetPriority
AJAStatus SetPriority(AJAThreadPriority threadPriority)
Definition: threadimpl.cpp:425
STACK_SIZE
static const size_t STACK_SIZE
Definition: threadimpl.cpp:19
AJAThreadImpl::Attach
AJAStatus Attach(AJAThreadFunction *pThreadFunction, void *pUserContext)
Definition: threadimpl.cpp:566
AJAThreadImpl::GetPriority
AJAStatus GetPriority(AJAThreadPriority *pThreadPriority)
Definition: threadimpl.cpp:504
debug.h
Declares the AJADebug class.
AJAThreadImpl::SetRealTime
AJAStatus SetRealTime(AJAThreadRealTimePolicy policy, int priority)
Definition: threadimpl.cpp:522
AJAThreadImpl::mExiting
bool mExiting
Definition: threadimpl.h:59