• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • graphics API Reference
  • KDE Home
  • Contact Us
 

digikam

  • extragear
  • graphics
  • digikam
  • core
  • dplugins
  • generic
  • tools
  • mediaserver
  • upnpsdk
  • Neptune
  • Source
  • System
  • Posix
NptPosixThreads.cpp
Go to the documentation of this file.
1 /*****************************************************************
2 |
3 | Neptune - Threads :: Posix Implementation
4 |
5 | (c) 2001-2002 Gilles Boccon-Gibod
6 | Author: Gilles Boccon-Gibod ([email protected])
7 |
8  ****************************************************************/
9 
10 /*----------------------------------------------------------------------
11 | includes
12 +---------------------------------------------------------------------*/
13 #if defined(__SYMBIAN32__)
14 #include <stdio.h>
15 #endif
16 #include <pthread.h>
17 #include <unistd.h>
18 #include <time.h>
19 #include <sys/time.h>
20 #include <errno.h>
21 
22 #include "NptConfig.h"
23 #include "NptTypes.h"
24 #include "NptThreads.h"
25 #include "NptLogging.h"
26 #include "NptTime.h"
27 #include "NptSystem.h"
28 #include "NptUtils.h"
29 #include "NptAutoreleasePool.h"
30 
31 /*----------------------------------------------------------------------
32 | logging
33 +---------------------------------------------------------------------*/
34 NPT_SET_LOCAL_LOGGER("neptune.threads.posix")
35 
36 /*----------------------------------------------------------------------
37 | NPT_PosixMutex
38 +---------------------------------------------------------------------*/
39 class NPT_PosixMutex : public NPT_MutexInterface
40 {
41 public:
42  // methods
43  NPT_PosixMutex();
44  ~NPT_PosixMutex() override;
45 
46  // NPT_Mutex methods
47  NPT_Result Lock() override;
48  NPT_Result Unlock() override;
49 
50 private:
51  // members
52  pthread_mutex_t m_Mutex;
53 };
54 
55 /*----------------------------------------------------------------------
56 | NPT_PosixMutex::NPT_PosixMutex
57 +---------------------------------------------------------------------*/
58 NPT_PosixMutex::NPT_PosixMutex()
59 {
60  // Recursive by default
61  pthread_mutexattr_t attr;
62  pthread_mutexattr_init(&attr);
63  pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
64 
65  pthread_mutex_init(&m_Mutex, &attr);
66 }
67 
68 /*----------------------------------------------------------------------
69 | NPT_PosixMutex::~NPT_PosixMutex
70 +---------------------------------------------------------------------*/
71 NPT_PosixMutex::~NPT_PosixMutex()
72 {
73  pthread_mutex_destroy(&m_Mutex);
74 }
75 
76 /*----------------------------------------------------------------------
77 | NPT_PosixMutex::Lock
78 +---------------------------------------------------------------------*/
79 NPT_Result
80 NPT_PosixMutex::Lock()
81 {
82  pthread_mutex_lock(&m_Mutex);
83  return NPT_SUCCESS;
84 }
85 
86 /*----------------------------------------------------------------------
87 | NPT_PosixMutex::Unlock
88 +---------------------------------------------------------------------*/
89 NPT_Result
90 NPT_PosixMutex::Unlock()
91 {
92  pthread_mutex_unlock(&m_Mutex);
93  return NPT_SUCCESS;
94 }
95 
96 /*----------------------------------------------------------------------
97 | NPT_Mutex::NPT_Mutex
98 +---------------------------------------------------------------------*/
99 NPT_Mutex::NPT_Mutex()
100 {
101  m_Delegate = new NPT_PosixMutex();
102 }
103 
104 /*----------------------------------------------------------------------
105 | NPT_PosixSharedVariable
106 +---------------------------------------------------------------------*/
107 class NPT_PosixSharedVariable : public NPT_SharedVariableInterface
108 {
109 public:
110  // methods
111  NPT_PosixSharedVariable(int value);
112  ~NPT_PosixSharedVariable() override;
113  void SetValue(int value) override;
114  int GetValue() override;
115  NPT_Result WaitUntilEquals(int value, NPT_Timeout timeout) override;
116  NPT_Result WaitWhileEquals(int value, NPT_Timeout timeout) override;
117 
118  private:
119  // members
120  volatile int m_Value;
121  pthread_mutex_t m_Mutex;
122  pthread_cond_t m_Condition;
123 };
124 
125 /*----------------------------------------------------------------------
126 | NPT_PosixSharedVariable::NPT_PosixSharedVariable
127 +---------------------------------------------------------------------*/
128 NPT_PosixSharedVariable::NPT_PosixSharedVariable(int value) :
129  m_Value(value)
130 {
131  pthread_mutex_init(&m_Mutex, NULL);
132  pthread_cond_init(&m_Condition, NULL);
133 }
134 
135 /*----------------------------------------------------------------------
136 | NPT_PosixSharedVariable::~NPT_PosixSharedVariable
137 +---------------------------------------------------------------------*/
138 NPT_PosixSharedVariable::~NPT_PosixSharedVariable()
139 {
140  pthread_cond_destroy(&m_Condition);
141  pthread_mutex_destroy(&m_Mutex);
142 }
143 
144 /*----------------------------------------------------------------------
145 | NPT_PosixSharedVariable::SetValue
146 +---------------------------------------------------------------------*/
147 void
148 NPT_PosixSharedVariable::SetValue(int value)
149 {
150  pthread_mutex_lock(&m_Mutex);
151  m_Value = value;
152  pthread_cond_broadcast(&m_Condition);
153  pthread_mutex_unlock(&m_Mutex);
154 }
155 
156 /*----------------------------------------------------------------------
157 | NPT_PosixSharedVariable::GetValue
158 +---------------------------------------------------------------------*/
159 int
160 NPT_PosixSharedVariable::GetValue()
161 {
162  // we assume that int read/write are atomic on the platform
163  return m_Value;
164 }
165 
166 /*----------------------------------------------------------------------
167 | NPT_PosixSharedVariable::WaitUntilEquals
168 +---------------------------------------------------------------------*/
169 NPT_Result
170 NPT_PosixSharedVariable::WaitUntilEquals(int value, NPT_Timeout timeout)
171 {
172  NPT_Result result = NPT_SUCCESS;
173  struct timespec timed;
174 
175  if (timeout != NPT_TIMEOUT_INFINITE) {
176  // get current time from system
177  struct timeval now;
178  if (gettimeofday(&now, NULL)) {
179  return NPT_FAILURE;
180  }
181 
182  now.tv_usec += timeout * 1000;
183  if (now.tv_usec >= 1000000) {
184  now.tv_sec += now.tv_usec / 1000000;
185  now.tv_usec = now.tv_usec % 1000000;
186  }
187 
188  // setup timeout
189  timed.tv_sec = now.tv_sec;
190  timed.tv_nsec = now.tv_usec * 1000;
191  }
192 
193  pthread_mutex_lock(&m_Mutex);
194  while (value != m_Value) {
195  if (timeout == NPT_TIMEOUT_INFINITE) {
196  pthread_cond_wait(&m_Condition, &m_Mutex);
197  } else {
198  int wait_res = pthread_cond_timedwait(&m_Condition, &m_Mutex, &timed);
199  if (wait_res == ETIMEDOUT) {
200  result = NPT_ERROR_TIMEOUT;
201  break;
202  }
203  }
204  }
205  pthread_mutex_unlock(&m_Mutex);
206 
207  return result;
208 }
209 
210 /*----------------------------------------------------------------------
211 | NPT_PosixSharedVariable::WaitWhileEquals
212 +---------------------------------------------------------------------*/
213 NPT_Result
214 NPT_PosixSharedVariable::WaitWhileEquals(int value, NPT_Timeout timeout)
215 {
216  NPT_Result result = NPT_SUCCESS;
217  struct timespec timed;
218 
219  if (timeout != NPT_TIMEOUT_INFINITE) {
220  // get current time from system
221  struct timeval now;
222  if (gettimeofday(&now, NULL)) {
223  return NPT_FAILURE;
224  }
225 
226  now.tv_usec += timeout * 1000;
227  if (now.tv_usec >= 1000000) {
228  now.tv_sec += now.tv_usec / 1000000;
229  now.tv_usec = now.tv_usec % 1000000;
230  }
231 
232  // setup timeout
233  timed.tv_sec = now.tv_sec;
234  timed.tv_nsec = now.tv_usec * 1000;
235  }
236 
237  pthread_mutex_lock(&m_Mutex);
238  while (value == m_Value) {
239  if (timeout == NPT_TIMEOUT_INFINITE) {
240  pthread_cond_wait(&m_Condition, &m_Mutex);
241  } else {
242  int wait_res = pthread_cond_timedwait(&m_Condition, &m_Mutex, &timed);
243  if (wait_res == ETIMEDOUT) {
244  result = NPT_ERROR_TIMEOUT;
245  break;
246  }
247  }
248  }
249  pthread_mutex_unlock(&m_Mutex);
250 
251  return result;
252 }
253 
254 /*----------------------------------------------------------------------
255 | NPT_SharedVariable::NPT_SharedVariable
256 +---------------------------------------------------------------------*/
257 NPT_SharedVariable::NPT_SharedVariable(int value)
258 {
259  m_Delegate = new NPT_PosixSharedVariable(value);
260 }
261 
262 /*----------------------------------------------------------------------
263 | NPT_PosixAtomicVariable
264 +---------------------------------------------------------------------*/
265 class NPT_PosixAtomicVariable : public NPT_AtomicVariableInterface
266 {
267  public:
268  // methods
269  NPT_PosixAtomicVariable(int value);
270  ~NPT_PosixAtomicVariable() override;
271  int Increment() override;
272  int Decrement() override;
273  int GetValue() override;
274  void SetValue(int value) override;
275 
276  private:
277  // members
278  volatile int m_Value;
279  pthread_mutex_t m_Mutex;
280 };
281 
282 /*----------------------------------------------------------------------
283 | NPT_PosixAtomicVariable::NPT_PosixAtomicVariable
284 +---------------------------------------------------------------------*/
285 NPT_PosixAtomicVariable::NPT_PosixAtomicVariable(int value) :
286  m_Value(value)
287 {
288  pthread_mutex_init(&m_Mutex, NULL);
289 }
290 
291 /*----------------------------------------------------------------------
292 | NPT_PosixAtomicVariable::~NPT_PosixAtomicVariable
293 +---------------------------------------------------------------------*/
294 NPT_PosixAtomicVariable::~NPT_PosixAtomicVariable()
295 {
296  pthread_mutex_destroy(&m_Mutex);
297 }
298 
299 /*----------------------------------------------------------------------
300 | NPT_PosixAtomicVariable::Increment
301 +---------------------------------------------------------------------*/
302 int
303 NPT_PosixAtomicVariable::Increment()
304 {
305  int value;
306 
307  pthread_mutex_lock(&m_Mutex);
308  value = ++m_Value;
309  pthread_mutex_unlock(&m_Mutex);
310 
311  return value;
312 }
313 
314 /*----------------------------------------------------------------------
315 | NPT_PosixAtomicVariable::Decrement
316 +---------------------------------------------------------------------*/
317 int
318 NPT_PosixAtomicVariable::Decrement()
319 {
320  int value;
321 
322  pthread_mutex_lock(&m_Mutex);
323  value = --m_Value;
324  pthread_mutex_unlock(&m_Mutex);
325 
326  return value;
327 }
328 
329 /*----------------------------------------------------------------------
330 | NPT_PosixAtomicVariable::GetValue
331 +---------------------------------------------------------------------*/
332 int
333 NPT_PosixAtomicVariable::GetValue()
334 {
335  // we assume that int read/write are atomic on the platform
336  return m_Value;
337 }
338 
339 /*----------------------------------------------------------------------
340 | NPT_PosixAtomicVariable::SetValue
341 +---------------------------------------------------------------------*/
342 void
343 NPT_PosixAtomicVariable::SetValue(int value)
344 {
345  pthread_mutex_lock(&m_Mutex);
346  m_Value = value;
347  pthread_mutex_unlock(&m_Mutex);
348 }
349 
350 /*----------------------------------------------------------------------
351 | NPT_AtomicVariable::NPT_AtomicVariable
352 +---------------------------------------------------------------------*/
353 NPT_AtomicVariable::NPT_AtomicVariable(int value)
354 {
355  m_Delegate = new NPT_PosixAtomicVariable(value);
356 }
357 
358 /*----------------------------------------------------------------------
359 | NPT_PosixThread
360 +---------------------------------------------------------------------*/
361 class NPT_PosixThread : public NPT_ThreadInterface
362 {
363  public:
364  // methods
365  NPT_PosixThread(NPT_Thread* delegator,
366  NPT_Runnable& target,
367  bool detached);
368  ~NPT_PosixThread() override;
369  NPT_Result Start() override;
370  NPT_Result Wait(NPT_Timeout timeout = NPT_TIMEOUT_INFINITE) override;
371  NPT_Result SetPriority(int priority) override;
372  NPT_Result GetPriority(int& priority) override;
373 
374  // class methods
375  static NPT_Result GetPriority(NPT_Thread::ThreadId thread_id, int& priority);
376  static NPT_Result SetPriority(NPT_Thread::ThreadId thread_id, int priority);
377 
378  private:
379  // class methods
380  static void* EntryPoint(void* argument);
381 
382  // NPT_Runnable methods
383  void Run() override;
384 
385  // NPT_Interruptible methods
386  NPT_Result Interrupt() override { return NPT_ERROR_NOT_IMPLEMENTED; }
387 
388  // members
389  NPT_Thread* m_Delegator;
390  NPT_Runnable& m_Target;
391  bool m_Detached;
392  pthread_t m_ThreadId;
393  bool m_Joined;
394  NPT_PosixMutex m_JoinLock;
395  NPT_SharedVariable m_Done;
396 };
397 
398 /*----------------------------------------------------------------------
399 | NPT_PosixThread::NPT_PosixThread
400 +---------------------------------------------------------------------*/
401 NPT_PosixThread::NPT_PosixThread(NPT_Thread* delegator,
402  NPT_Runnable& target,
403  bool detached) :
404  m_Delegator(delegator),
405  m_Target(target),
406  m_Detached(detached),
407  m_ThreadId(0),
408  m_Joined(false)
409 {
410  NPT_LOG_FINE("NPT_PosixThread::NPT_PosixThread");
411  m_Done.SetValue(0);
412 }
413 
414 /*----------------------------------------------------------------------
415 | NPT_PosixThread::~NPT_PosixThread
416 +---------------------------------------------------------------------*/
417 NPT_PosixThread::~NPT_PosixThread()
418 {
419  //NPT_Debug("NPT_PosixThread::~NPT_PosixThread %d\n", m_ThreadId);
420 
421  if (!m_Detached) {
422  // we're not detached, and not in the Run() method, so we need to
423  // wait until the thread is done
424  Wait();
425  }
426 }
427 
428 /*----------------------------------------------------------------------
429 | NPT_Thread::GetCurrentThreadId
430 +---------------------------------------------------------------------*/
431 NPT_Thread::ThreadId
432 NPT_Thread::GetCurrentThreadId()
433 {
434  pthread_t pid = pthread_self();
435  return *(NPT_Thread::ThreadId*)((void*)pid);
436 }
437 
438 /*----------------------------------------------------------------------
439 | NPT_Thread::SetCurrentThreadPriority
440 +---------------------------------------------------------------------*/
441 NPT_Result
442 NPT_Thread::SetCurrentThreadPriority(int priority)
443 {
444  return NPT_PosixThread::SetPriority(GetCurrentThreadId(), priority);
445 }
446 
447 /*----------------------------------------------------------------------
448 | NPT_Thread::GetCurrentThreadPriority
449 +---------------------------------------------------------------------*/
450 NPT_Result
451 NPT_Thread::GetCurrentThreadPriority(int& priority)
452 {
453  return NPT_PosixThread::GetPriority(GetCurrentThreadId(), priority);
454 }
455 
456 /*----------------------------------------------------------------------
457 | NPT_PosixThread::EntryPoint
458 +---------------------------------------------------------------------*/
459 void*
460 NPT_PosixThread::EntryPoint(void* argument)
461 {
462  NPT_PosixThread* thread = reinterpret_cast<NPT_PosixThread*>(argument);
463 
464  NPT_LOG_FINER("NPT_PosixThread::EntryPoint - in =======================");
465 
466 #if defined(NPT_CONFIG_HAVE_AUTORELEASE_POOL)
467  // ensure there is the top level autorelease pool for each thread
468  NPT_AutoreleasePool pool;
469 #endif
470 
471  // get the thread ID from this context, because m_ThreadId may not yet
472  // have been set by the parent thread in the Start() method
473  thread->m_ThreadId = pthread_self();
474 
475  // set random seed per thread
476  NPT_TimeStamp now;
477  NPT_System::GetCurrentTimeStamp(now);
478  NPT_System::SetRandomSeed((unsigned int)(now.ToNanos() + (long)thread->m_ThreadId));
479 
480  // run the thread
481  thread->Run();
482 
483  // Logging here will cause a crash on exit because LogManager may already be destroyed
484  //NPT_LOG_FINE("NPT_PosixThread::EntryPoint - out ======================");
485 
486  // we're done with the thread object
487  // if we're detached, we need to delete ourselves
488  if (thread->m_Detached) {
489  delete thread->m_Delegator;
490  } else {
491  // notify we're done
492  thread->m_Done.SetValue(1);
493  }
494 
495  // done
496  return NULL;
497 }
498 
499 /*----------------------------------------------------------------------
500 | NPT_PosixThread::Start
501 +---------------------------------------------------------------------*/
502 NPT_Result
503 NPT_PosixThread::Start()
504 {
505  NPT_LOG_FINER("---- Creating thread");
506 
507  // reset values
508  m_Joined = false;
509  m_ThreadId = 0;
510  m_Done.SetValue(0);
511 
512  pthread_attr_t *attributes = NULL;
513 
514 #if defined(NPT_CONFIG_THREAD_STACK_SIZE)
515  pthread_attr_t stack_size_attributes;
516  pthread_attr_init(&stack_size_attributes);
517  pthread_attr_setstacksize(&stack_size_attributes, NPT_CONFIG_THREAD_STACK_SIZE);
518  attributes = &stack_size_attributes;
519 #endif
520 
521  // use local copies of some of the object's members, because for
522  // detached threads, the object instance may have deleted itself
523  // before the pthread_create() function returns
524  bool detached = m_Detached;
525 
526  // create the native thread
527  pthread_t thread_id;
528  int result = pthread_create(&thread_id, attributes, EntryPoint,
529  static_cast<NPT_PosixThread*>(this));
530  NPT_LOG_FINER_2("---- Thread Created: id = %d, res=%d",
531  thread_id, result);
532  if (result != 0) {
533  // failed
534  return NPT_ERROR_ERRNO(result);
535  } else {
536  // detach the thread if we're not joinable
537  if (detached) {
538  pthread_detach(thread_id);
539  } else {
540  // store the thread ID (NOTE: this is also done by the thread Run() method
541  // but it is necessary to do it from both contexts, because we don't know
542  // which one will need it first.)
543  m_ThreadId = thread_id;
544  }
545  return NPT_SUCCESS;
546  }
547 }
548 
549 /*----------------------------------------------------------------------
550 | NPT_PosixThread::Run
551 +---------------------------------------------------------------------*/
552 void
553 NPT_PosixThread::Run()
554 {
555  m_Target.Run();
556 }
557 
558 /*----------------------------------------------------------------------
559 | NPT_PosixThread::Wait
560 +---------------------------------------------------------------------*/
561 NPT_Result
562 NPT_PosixThread::Wait(NPT_Timeout timeout /* = NPT_TIMEOUT_INFINITE */)
563 {
564  void* return_value;
565  int result;
566 
567  // Note: Logging here will cause a crash on exit because LogManager may already be destroyed
568  // if this object is global or static as well
569  //NPT_LOG_FINE_1("NPT_PosixThread::Wait - waiting for id %d", m_ThreadId);
570 
571  // check that we're not detached
572  if (m_ThreadId == 0 || m_Detached) {
573  return NPT_FAILURE;
574  }
575 
576  // wait for the thread to finish
577  m_JoinLock.Lock();
578  if (m_Joined) {
579  result = 0;
580  } else {
581  if (timeout != NPT_TIMEOUT_INFINITE) {
582  if (NPT_FAILED(m_Done.WaitUntilEquals(1, timeout))) {
583  result = -1;
584  goto timedout;
585  }
586  }
587 
588  result = pthread_join(m_ThreadId, &return_value);
589  m_Joined = true;
590  }
591 
592 timedout:
593  m_JoinLock.Unlock();
594  if (result != 0) {
595  return NPT_FAILURE;
596  } else {
597  return NPT_SUCCESS;
598  }
599 }
600 
601 /*----------------------------------------------------------------------
602 | NPT_PosixThread::SetPriority
603 +---------------------------------------------------------------------*/
604 NPT_Result
605 NPT_PosixThread::SetPriority(int priority)
606 {
607  // check that we're started
608  if (m_ThreadId == 0) {
609  return NPT_FAILURE;
610  }
611 
612  return NPT_PosixThread::SetPriority((NPT_Thread::ThreadId)m_ThreadId, priority);
613 }
614 
615 /*----------------------------------------------------------------------
616 | NPT_PosixThread::SetPriority
617 +---------------------------------------------------------------------*/
618 NPT_Result
619 NPT_PosixThread::SetPriority(NPT_Thread::ThreadId thread_id, int priority)
620 {
621  // check that we're started
622  if (thread_id == 0) {
623  return NPT_FAILURE;
624  }
625 
626  /* sched_priority will be the priority of the thread */
627  struct sched_param sp;
628  int policy;
629  int result = pthread_getschedparam((pthread_t)thread_id, &policy, &sp);
630 
631  NPT_LOG_FINER_3("Current thread policy: %d, priority: %d, new priority: %d",
632  policy, sp.sched_priority, priority);
633  NPT_LOG_FINER_4("Thread max(SCHED_OTHER): %d, max(SCHED_RR): %d \
634  min(SCHED_OTHER): %d, min(SCHED_RR): %d",
635  sched_get_priority_max(SCHED_OTHER),
636  sched_get_priority_max(SCHED_RR),
637  sched_get_priority_min(SCHED_OTHER),
638  sched_get_priority_min(SCHED_RR));
639 
640  sp.sched_priority = priority;
641 
642  /*
643  if (sp.sched_priority <= 0)
644  sp.sched_priority += sched_get_priority_max (policy = SCHED_OTHER);
645  else
646  sp.sched_priority += sched_get_priority_min (policy = SCHED_RR);
647  */
648 
649  /* scheduling parameters of target thread */
650  result = pthread_setschedparam((pthread_t)thread_id, policy, &sp);
651 
652  return (result==0)?NPT_SUCCESS:NPT_ERROR_ERRNO(result);
653 }
654 
655 /*----------------------------------------------------------------------
656 | NPT_PosixThread::GetPriority
657 +---------------------------------------------------------------------*/
658 NPT_Result
659 NPT_PosixThread::GetPriority(int& priority)
660 {
661  // check that we're started
662  if (m_ThreadId == 0) {
663  return NPT_FAILURE;
664  }
665 
666  return NPT_PosixThread::GetPriority((NPT_Thread::ThreadId)m_ThreadId, priority);
667 }
668 
669 /*----------------------------------------------------------------------
670 | NPT_PosixThread::GetPriority
671 +---------------------------------------------------------------------*/
672 NPT_Result
673 NPT_PosixThread::GetPriority(NPT_Thread::ThreadId thread_id, int& priority)
674 {
675  // check that we're started
676  if (thread_id == 0) {
677  return NPT_FAILURE;
678  }
679 
680  struct sched_param sp;
681  int policy;
682 
683  int result = pthread_getschedparam((pthread_t)thread_id, &policy, &sp);
684  NPT_LOG_FINER_1("Current thread priority: %d", sp.sched_priority);
685 
686  priority = sp.sched_priority;
687  return (result==0)?NPT_SUCCESS:NPT_ERROR_ERRNO(result);
688 }
689 
690 /*----------------------------------------------------------------------
691 | NPT_Thread::NPT_Thread
692 +---------------------------------------------------------------------*/
693 NPT_Thread::NPT_Thread(bool detached)
694 {
695  m_Delegate = new NPT_PosixThread(this, *this, detached);
696 }
697 
698 /*----------------------------------------------------------------------
699 | NPT_Thread::NPT_Thread
700 +---------------------------------------------------------------------*/
701 NPT_Thread::NPT_Thread(NPT_Runnable& target, bool detached)
702 {
703  m_Delegate = new NPT_PosixThread(this, target, detached);
704 }
705 
NPT_SharedVariableInterface::WaitWhileEquals
virtual NPT_Result WaitWhileEquals(int value, NPT_Timeout timeout=NPT_TIMEOUT_INFINITE)=0
NPT_Thread
Definition: NptThreads.h:233
NPT_SUCCESS
#define NPT_SUCCESS
Result indicating that the operation or call succeeded.
Definition: NptResults.h:104
NPT_LOG_FINER_2
#define NPT_LOG_FINER_2(_msg, _arg1, _arg2)
Definition: NptLogging.h:423
NPT_ERROR_NOT_IMPLEMENTED
#define NPT_ERROR_NOT_IMPLEMENTED
Definition: NptResults.h:140
NPT_SharedVariableInterface::SetValue
virtual void SetValue(int value)=0
NPT_SET_LOCAL_LOGGER
#define NPT_SET_LOCAL_LOGGER(_name)
Definition: NptLogging.h:283
NPT_Mutex::NPT_Mutex
NPT_Mutex()
Definition: NptPosixThreads.cpp:99
NptThreads.h
NptAutoreleasePool.h
NPT_FAILURE
#define NPT_FAILURE
Result indicating an unspecified failure condition.
Definition: NptResults.h:107
NPT_Runnable
Definition: NptThreads.h:209
NPT_System::SetRandomSeed
static NPT_Result SetRandomSeed(unsigned int seed)
Definition: NptPosixSystem.cpp:170
NPT_System::GetCurrentTimeStamp
static NPT_Result GetCurrentTimeStamp(NPT_TimeStamp &now)
Definition: NptPosixSystem.cpp:88
NptLogging.h
Header file for logging.
value
qulonglong value
Definition: itemviewutilities.cpp:530
NPT_AtomicVariableInterface::GetValue
virtual int GetValue()=0
NPT_TimeStamp
Definition: NptTime.h:50
NPT_TIMEOUT_INFINITE
const int NPT_TIMEOUT_INFINITE
Definition: NptConstants.h:42
NPT_LOG_FINER
#define NPT_LOG_FINER(_msg)
Definition: NptLogging.h:419
NPT_LOG_FINER_4
#define NPT_LOG_FINER_4(_msg, _arg1, _arg2, _arg3, _arg4)
Definition: NptLogging.h:427
NPT_AtomicVariable::NPT_AtomicVariable
NPT_AtomicVariable(int value=0)
Definition: NptNullThreads.cpp:39
NPT_FAILED
#define NPT_FAILED(result)
Definition: NptResults.h:97
NPT_ThreadInterface::Start
virtual NPT_Result Start()=0
NPT_AtomicVariableInterface
Definition: NptThreads.h:176
NPT_SharedVariable
Definition: NptThreads.h:149
NPT_AtomicVariableInterface::SetValue
virtual void SetValue(int value)=0
NptConfig.h
NPT_ThreadInterface::GetPriority
virtual NPT_Result GetPriority(int &priority)=0
NPT_Thread::SetCurrentThreadPriority
static NPT_Result SetCurrentThreadPriority(int priority)
Definition: NptPosixThreads.cpp:442
NPT_MutexInterface
Definition: NptThreads.h:64
NptSystem.h
NPT_AutoreleasePool
Definition: NptAutoreleasePool.h:47
NPT_ERROR_TIMEOUT
#define NPT_ERROR_TIMEOUT
Definition: NptResults.h:142
NPT_Runnable::Run
virtual void Run()=0
NPT_LOG_FINER_1
#define NPT_LOG_FINER_1(_msg, _arg1)
Definition: NptLogging.h:421
Digikam::cimg_library::cimg::argument
const char * argument(const unsigned int nb, const int argc, const char *const *const argv, const unsigned int nb_singles=0,...)
Definition: CImg.h:5743
NPT_ThreadInterface
Definition: NptThreads.h:219
NPT_CONFIG_THREAD_STACK_SIZE
#define NPT_CONFIG_THREAD_STACK_SIZE
Definition: NptConfig.h:340
NPT_ERROR_ERRNO
#define NPT_ERROR_ERRNO(e)
Definition: NptResults.h:156
NptUtils.h
NptTime.h
NPT_Thread::GetCurrentThreadPriority
static NPT_Result GetCurrentThreadPriority(int &priority)
Definition: NptPosixThreads.cpp:451
NPT_ThreadInterface::SetPriority
virtual NPT_Result SetPriority(int)
Definition: NptThreads.h:226
NPT_AtomicVariableInterface::Decrement
virtual int Decrement()=0
NPT_LOG_FINER_3
#define NPT_LOG_FINER_3(_msg, _arg1, _arg2, _arg3)
Definition: NptLogging.h:425
NptTypes.h
NPT_Thread::ThreadId
unsigned long ThreadId
Definition: NptThreads.h:237
NPT_Thread::GetCurrentThreadId
static ThreadId GetCurrentThreadId()
Definition: NptPosixThreads.cpp:432
NPT_TimeStamp::ToNanos
NPT_Int64 ToNanos() const
Definition: NptTime.h:76
NPT_SharedVariableInterface
Definition: NptThreads.h:135
NPT_ThreadInterface::Wait
virtual NPT_Result Wait(NPT_Timeout timeout=NPT_TIMEOUT_INFINITE)=0
NPT_Interruptible::Interrupt
virtual NPT_Result Interrupt()=0
NPT_Timeout
NPT_Int32 NPT_Timeout
Definition: NptTypes.h:63
NPT_SharedVariableInterface::WaitUntilEquals
virtual NPT_Result WaitUntilEquals(int value, NPT_Timeout timeout=NPT_TIMEOUT_INFINITE)=0
NPT_SharedVariable::NPT_SharedVariable
NPT_SharedVariable(int value=0)
Definition: NptPosixThreads.cpp:257
NPT_Result
int NPT_Result
Definition: NptTypes.h:56
NPT_SharedVariableInterface::GetValue
virtual int GetValue()=0
NPT_Thread::NPT_Thread
NPT_Thread(bool detached=false)
Definition: NptPosixThreads.cpp:693
NULL
#define NULL
Definition: NptConstants.h:39
NPT_AtomicVariableInterface::Increment
virtual int Increment()=0
NPT_LOG_FINE
#define NPT_LOG_FINE(_msg)
Definition: NptLogging.h:399
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Thu Dec 12 2019 03:10:14 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

digikam

Skip menu "digikam"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages
-->

graphics API Reference

Skip menu "graphics API Reference"
  • digikam
  • KDiagram
  •     KChart
  •     KGantt
  • KPhotoAlbum
  •   AndroidRemoteControl
  • Krita
  •   libs
  •     KritaBasicFlakes
  •     brush
  •     KritaUndo2
  •     KritaFlake
  •     image
  •     KritaPlugin
  •     Krita
  •     KritaOdf
  •     KritaPigment
  •     KritaStore
  •     ui
  •     KritaWidgets
  •     KritaWidgetUtils
  •   plugins
  •     Assitants
  •     Extensions
  •     Filters
  •         KritaText
  •         KritaTextLayout
  •     Generators
  •     Formats
  •             src
  •     PaintOps
  •       libpaintop
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal