AGX Dynamics  2.37.2.0
Thread.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #ifdef _MSC_VER
20 # pragma warning(push)
21 # pragma warning( disable: 4275 ) // warning C4275: non dll-interface class
22 # pragma warning(disable: 4251) // warning C4251: class X needs to have dll-interface to be used by clients of class Y
23 #endif
24 
25 
26 #include <agx/agx.h>
27 #include <agx/Vector.h>
28 #include <agx/HashTable.h>
29 #include <agx/Timer.h>
30 #include <agx/Task.h>
32 
34 #include <agxData/EntityStorage.h>
35 
36 #include <agx/AtomicValue.h>
37 #include <agx/Job.h>
38 #include <agx/Uuid.h>
39 #include <agx/Notify.h>
40 
41 #include <queue>
42 #include <thread>
43 
44 // Set to 1 to enable thread timeline reporting of internal steps
45 #define ENABLE_VERBOSE_THREAD_TIMELINE 0
46 
47 
48 #define AGX_MAX_NUM_THREADS 1024
49 
50 
51 extern "C"
52 {
53  void agxFlushThreadLogs();
54 }
55 
56 namespace agxData
57 {
58  class EntityStorage;
59  class EntityModel;
60 }
61 
62 
63 
64 
65 
66 namespace agx
67 {
68  class TiXmlElement;
69  class Task;
70 
71 
72  // AGX_DECLARE_POINTER_TYPES(Thread);
73  // AGX_DECLARE_VECTOR_TYPES(Thread);
74 
75 
76 
83  {
84  public:
85 
89  enum ThreadState {
90  THREAD_NEW = 0, // When a BasicThread is created
91  THREAD_RUNNING = 1, // start has been called
92  THREAD_DETACHED = 2, // detach has been called
93  THREAD_DONE = 3, // After run() is done executing
94  THREAD_JOINED = 4, // After join() has been called
95  THREAD_CANCELLED = 5 // After cancel but before join
96  };
97 
101  BasicThread();
102 
103  BasicThread( const BasicThread& other ) = delete;
104 
105  BasicThread& operator=(const BasicThread& rhs ) = delete;
106 
110  virtual ~BasicThread() = default;
111 
116  virtual void run() { }
117 
125  bool start();
126 
134  void cancel();
135 
139  bool join();
140 
141 
145  void detach();
146 
150  inline bool joinable();
151 
155  inline unsigned int getThreadState();
156 
157 
158 
159 
173  bool setThreadAffinity(agx::UInt64 cpumask);
174 
175 
179  static std::thread::native_handle_type getCurrentThreadHandle();
180 
181 
182  private:
183  void launchThread();
184 
185  protected:
186  std::thread m_handle;
187  std::atomic< unsigned int> m_state;
188  private:
189  std::mutex m_handleMutex;
190  };
191 
192 
193 
199  {
200  public:
201 
202 
203  // The types used when communicating with the thread local storage facilities.
204  // The key type is an integer type and the data type is a pointer type.
205  #ifdef _WIN32
206  typedef unsigned long ThreadStorageKey; // Should be DWORD
207  typedef void* ThreadStorageData; // Should be LPVOID
208  #else
209  typedef pthread_key_t ThreadStorageKey;
210  typedef void* ThreadStorageData;
211  #endif
212 
213  typedef std::mt19937 RandomGenerator;
214 
218  bool start();
219 
223  void stop();
224 
231  Index getId() const;
232 
243  Index getIndex() const;
244 
248  static Thread *getCurrentThread();
249 
255  static std::string getCurrentThreadDescription();
256 
260  static Thread *getThread(size_t id);
261 
265  static Thread *getMainThread();
266 
271  static void makeCurrentThreadMainThread();
272 
277  static Thread *registerAsAgxThread();
278 
283  static void unregisterAsAgxThread();
284 
290  RandomGenerator& getRandomGenerator();
291 
292 
296  static bool isMainThread();
297 
298 
302  static void shutdown();
303 
304  static bool isShuttingDown();
305 
306 
308  static void setEnableJobTimeline(bool flag);
309  static bool getEnableJobTimeline();
310 
319  void reportSystemJob(
320  UInt64 startTick, UInt64 endTick,
321  const char* description,
322  const char* extraDataTitle = nullptr,
323  agx::Real64 extraData = 0.0);
324 
328  Real getOverheadTime() const;
329 
333  void resetOverheadTime();
334 
335  // Allocations
336  // void *allocateBytes(size_t numBytes);
337  // void *deallocateBytes(void *ptr);
338 
343  agx::Uuid generateUuid();
344 
345 
346 
347 
348 
349 
350 
351 
352  // Main thread is normally allocated automatically, special usage before main is entered
353  static void initThreadSystem();
354 
355  // Dump profiling logs, called by Simulation
356  static void exportAllTimelines();
357  static void resetStartTick();
358  static void flushTimelineLogs();
359 
360 
361  /*
362  * Methods used for manipulating the thread local storage.
363  */
364 
366  static ThreadStorageKey allocatePerThreadStorage();
368  static ThreadStorageData readPerThreadStorage( ThreadStorageKey key );
370  static void writePerThreadStorage( ThreadStorageKey key, ThreadStorageData data);
372  static void freePerThreadStorage( ThreadStorageKey key );
373 
374  static bool immediateLogging;
375  static int log(const char *format, ...);
376  static void flushLogs();
377  agxData::EntityStorage *getDefaultStorage(agxData::EntityModel *entity);
378 
379  agxData::EntityStorageRef popTimelineEntryStorage();
380 
381 
382  static void addTask(Task *task);
383 
384  // Threads that aren't "real" AGX threads, i.e., registered threads, get
385  // a pseudo-ID in this table. These IDs are unrelated from the IDs of the
386  // "real" AGX threads.
388  static Thread::ThreadIdTable* getPromotedThreads();
389 
390  protected:
391  Thread(Index id);
392  Thread(const Thread&) = delete;
393  virtual ~Thread();
394 
395  private:
396 
397 
398 
399  friend void AGXCORE_EXPORT setNumThreads(size_t numThreads);
400  friend void AGXPHYSICS_EXPORT shutdown();
401 
402  class MainThreadSingleton;
403  static Thread *initMainThread();
404 
405  static void performNumThreadsChange();
406  void startWaitTimer();
407  void stopWaitTimer();
408 
409  virtual void run();
410 
411  void freeDefaultStorages();
412  void spawn(Job *job);
413  void sortInsertJob(Job *job);
414 
415  void activate();
416  void completeFrame(Task *task);
417 
418  bool isActive() const;
419 
420 
421  template <bool THREAD_TIMELINE_STATISTICS>
422  void doWork();
423 
424  void doWork();
425  void blockingDoWork();
426 
427  void stealWork();
428  void wakeupThreads();
429  void pushTargetJob(Thread *target, Job *job, bool activateTarget = true);
430  static void taskCompleted(Task *task);
431 
432  void initialize();
433  void sleep();
434 
435  Job *getExecutionJob();
436 
437  Index getRandomOtherThreadId(Index excludeIndex = InvalidIndex);
438 
439  friend class Block;
440 
441  friend class Job;
442  friend class Notify;
443 
444  private:
445  char *m_currentPathString;
446 
447  Notify::ThreadData *getNotifyData();
449 
450  friend class Task;
451 
452  // Simple linear congruential generator
453  class FastRandom
454  {
455  public:
456  FastRandom(UInt32 seed);
457  FastRandom();
458 
459  UInt32 operator() ();
460 
461  private:
462  static const UInt32 mod = ((1ULL << 32) - 5);
463  static const UInt32 mul = 69070U;
464 
465  void init(UInt32 seed);
466 
467  private:
468  UInt32 m_state;
469  };
470 
471  FastRandom m_fastRandom;
472 
473  struct Frame
474  {
475  inline Frame(Task *t = nullptr) : task(t), done(false) {}
476  inline Frame& operator=(const Frame& other) {task = other.task; done = other.done.load(); return *this;}
477  Task *task;
478  std::atomic<bool> done;
479  };
480 
481  #define AGX_THREAD_FRAME_STACK_MAX_DEPTH 64
482  Frame m_frames[AGX_THREAD_FRAME_STACK_MAX_DEPTH];
483  size_t m_numFrames;
484  size_t m_activationDepth;
485  std::atomic<Int32> m_activationCount;
486 
487  Thread *m_listNodeNext;
488 
489  agx::SpinMutex m_jobMutex;
490  JobPtrVector m_localJobs;
491 
492  struct JobCompare
493  {
494  AGX_FORCE_INLINE bool operator() (const Job *lhs, const Job *rhs) const
495  {
496  return lhs->getCostEstimate() < rhs->getCostEstimate();
497  }
498  };
499 
500  typedef std::priority_queue<Job *, agx::Vector<Job *>, JobCompare> JobQueue;
501  JobQueue m_sharedJobs;
502  JobQueue m_tmpJobs;
503 
504 
505  Timer m_wakeupTimer;
506  Timer m_sleepTimer;
507  size_t m_numSleep;
508 
509  // static THREAD_LOCAL_STORAGE Thread *s_currentThread;
510  bool m_isSleeping;
511  Block m_startBlock;
512  Block m_runBlock;
513  Block m_waitBlock;
514  agx::SpinMutex m_mutex;
515  std::atomic<bool> m_running;
516 
517  agx::SpinMutex m_pushMutex;
518  JobPtrVector m_pushedJobs;
519  std::atomic<Int32> m_pushCounter;
520 
521 
522  Index m_id;
523  Timer m_timer;
524  Timer m_overheadTimer;
525  Real m_waitTime;
526  Real m_totJobProcessTime;
527  Real m_totJobOverheadTime;
528  int m_totJobElements;
529  Real m_startupTimestamp;
530  Real m_shutdownTimestamp;
531 
532 
533  // std::ostringstream m_log;
534  static Thread *s_threads[AGX_MAX_NUM_THREADS];
535  static Thread *s_mainThread;
536  static Thread *s_mainWorkThread;
537  static Thread *s_ioThread;
538  static Callback1<Task *> s_taskCompletionCallback;
539 
540  agx::UuidGenerator m_uuidGenerator;
541  std::random_device m_randomDevice;
542  std::mt19937 m_mersienneTwister;
543  // Vector<AbstractMemoryPool *> m_pools;
544 
545  #if 0
546  template <typename T>
547  T *allocateLocalVector(LocalVector<T> *buffer);
548 
549  template <typename T>
550  void deallocateLocalVector(LocalVector<T> *buffer);
551  #endif
552 
553  private:
554 
555  friend class ThreadLocalAllocator;
556  void registerContainerAllocation(Container *container);
557  void unregisterContainerAllocation(Container *container);
558  void *allocateScratchPadBuffer(size_t numBytes);
559  void deallocateScratchPadBuffer(void *buffer, size_t numBytes);
560 
561  struct ScratchPadArea
562  {
563  ScratchPadArea() : buffer(nullptr), end(nullptr), head(nullptr), m_allocator("ScratchPad")
564  {}
565 
566  ~ScratchPadArea() { m_allocator.deallocateBytes(buffer); }
567 
568  char *buffer;
569  char *end;
570  char *head;
571  ByteAllocator m_allocator;
572  VectorPOD<Container *> m_activeAllocations;
573  };
574 
575  ScratchPadArea m_scratchPad;
576 
577 
578  static bool s_enableJobTimeline;
579  agxData::EntityStorageRef m_timelineEntries;
580 
581  static std::exception_ptr s_unhandledException;
582 
583 
584  struct LocalTimelineEntry
585  {
586  LocalTimelineEntry()
587  : jobType(UNKNOWN)
588  , startTick(0)
589  , endTick(0)
590  , poolSize(0)
591  , costEstimate(0)
592  , message(nullptr)
593  , job(nullptr)
594  , extraDataTitle(nullptr)
595  , extraData(0.0)
596  {}
597 
598  enum JobType { PRE, DISPATCH, POST, UNKNOWN };
599 
600  agx::TaskRef task;
601  JobType jobType;
602  agx::UInt64 startTick;
603  agx::UInt64 endTick;
604  agx::UInt32 poolSize;
605  agx::UInt32 costEstimate;
606  const char* message;
607  void* job;
608 
609  const char* extraDataTitle;
610  agx::Real64 extraData;
611  };
612 
613  Vector<LocalTimelineEntry> m_localTimelineEntries;
614  agx::SpinMutex m_timelineMutex;
615  AGX_DECLARE_POINTER_TYPES(TimelineExportKernel);
616 
617 
618  void exportTimelineEntries();
619  void reportTimelineJob(Job *job);
620  void pushTimelineEntry(const LocalTimelineEntry& entry);
621 
622  AGX_DECLARE_POINTER_TYPES(LogChunk);
623  class LogChunk : public Referenced
624  {
625  public:
626  LogChunk(size_t numBytes);
627  char* buffer;
628  char* head;
629  char* end;
630  LogChunkRef next;
631  size_t numAvailable();
632 
633  protected:
634  virtual ~LogChunk();
635  };
636 
637  struct LogEntry
638  {
639  LogEntry();
640  LogEntry(agx::UInt64 timestamp_, const char* message_);
641  agx::UInt64 timestamp;
642  const char* message;
643  };
644 
645  int logImplementation(const char* format, va_list ap);
646  static int cmpLogEntry(const LogEntry& entry1, const LogEntry& entry2);
647 
648  LogChunkRef m_logChunk;
649  VectorPOD<LogEntry> m_logEntries;
650 
652  DefaultStorageTable m_defaultStorageTable;
653 
654 
657  static ThreadStorageKey s_threadObject_key;
658  };
659 
661 
662 
663 
664 
665 
666 
667 
668  /* Implementation */
670 
671  inline bool BasicThread::joinable()
672  {
673  return m_handle.joinable();
674  }
675 
676 
677 
678  inline unsigned int BasicThread::getThreadState()
679  {
680  return m_state.load();
681  }
682 
683 
684 
685  AGX_FORCE_INLINE Index Thread::getId() const
686  {
687  return m_id;
688  }
689 
690  AGX_FORCE_INLINE Thread *Thread::getThread(size_t id)
691  {
692  agxAssert(s_threads[id]);
693  return s_threads[id];
694  }
695 
697  {
698  // The AGX threads store a pointer to their thread object in the thread local storage
699  // pointed to by 's_threadObject_key'. If the currently executing thread isn't a AgX
700  // thread, then nothing will have been written to 's_threadObject_key' and 0 is returned.
701  return static_cast<Thread*>( Thread::readPerThreadStorage(s_threadObject_key) );
702  }
703 
704  AGX_FORCE_INLINE Thread *Thread::getMainThread()
705  {
706  agxAssert(s_mainThread);
707  return s_mainThread;
708  }
709 
710  #if 0
711  AGX_FORCE_INLINE Thread *Thread::getMainWorkThread()
712  {
713  return s_mainWorkThread;
714  }
715  #endif
716 
717  AGX_FORCE_INLINE bool Thread::isMainThread() { return Thread::getCurrentThread() == s_mainThread; }
718  AGX_FORCE_INLINE bool Thread::isActive() const { return m_activationCount.load() > 0; }
719 
720  AGX_FORCE_INLINE void Thread::startWaitTimer()
721  {
722  m_timer.reset(true);
723  }
724 
725  AGX_FORCE_INLINE void Thread::stopWaitTimer()
726  {
727  m_timer.stop();
728  m_waitTime += (Real)m_timer.getTime();
729  }
730 
731  AGX_FORCE_INLINE Thread::RandomGenerator& Thread::getRandomGenerator()
732  {
733  return m_mersienneTwister;
734  }
735 
736  AGX_FORCE_INLINE Real Thread::getOverheadTime() const { return Real(m_overheadTimer.getTime()); }
737 
738 
739  inline int Thread::log(const char *format, ...)
740  {
741  va_list arguments;
742  va_start(arguments, format);
743  int result = Thread::getCurrentThread()->logImplementation(format, arguments);
744  va_end(arguments);
745  return result;
746  }
747 
748 
749  #if 0
750  AGX_FORCE_INLINE void *Thread::allocateBytes(size_t numBytes)
751  {
752  return m_byteAllocator.allocate(numBytes);
753  }
754 
755  AGX_FORCE_INLINE void *Thread::deallocateBytes(void *ptr)
756  {
757  m_byteAllocator.deallocateBytes(ptr);
758  }
759 
760  template <typename T>
761  AGX_FORCE_INLINE T *Thread::allocate()
762  {
763  return this->getPool<T>()->allocate();
764  }
765 
766  template <typename T>
767  AGX_FORCE_INLINE void Thread::deallocate(T *ptr)
768  {
769  this->getPool<T>()->deallocate(ptr);
770  }
771 
772 
773  template <typename T>
774  AGX_FORCE_INLINE T *Thread::create()
775  {
776  return this->getPool<T>()->create();
777  }
778 
779  template <typename T>
780  AGX_FORCE_INLINE void Thread::destroy(T *ptr)
781  {
782  this->getPool<T>()->destroy(ptr);
783  }
784 
785  template <typename T>
786  AGX_FORCE_INLINE MemoryPool<T> *Thread::getPool()
787  {
788  uint32_t id = agxData::getType<T>()->getId();
789  if (id >= m_pools.size())
790  m_pools.resize(id+1, 0);
791 
792  if (!m_pools[id])
793  m_pools[id] = new MemoryPool<T>;
794 
795  return static_cast<MemoryPool<T> *>(m_pools[id]);
796  }
797 
798  void setCurrentConstructionObject(void *ptr);
799  void *getCurrentConstructionObject();
800  #endif
801 
802 
803 
804 
805 
806  AGX_FORCE_INLINE void *Thread::allocateScratchPadBuffer(size_t numBytes)
807  {
808  /* Check if scratch pad is too small, which requires reallocation and updates to all existing container allocations */
809  if (m_scratchPad.head + numBytes > m_scratchPad.end)
810  {
811  size_t currentSize = m_scratchPad.end - m_scratchPad.buffer;
812  const Real growFactor = 1.5;
813  size_t newSize = (size_t)( Real(currentSize + numBytes) * growFactor );
814  // printf("Reallocating scratch pad for thread %d from %u to %u KB\n", this->getId(), (unsigned)(currentSize/1024), (unsigned)(newSize/1024));
815 
816  char *newBuffer = (char *)m_scratchPad.m_allocator.allocateBytes(newSize, 64);
817  agxAssertN(newBuffer, "Thread %d could not allocate %u bytes for job scratch pad!", this->getId(), (unsigned)newSize);
818  if (!newBuffer)
819  return nullptr;
820 
821  /* Copy active allocations */
822  size_t numUsed = m_scratchPad.head - m_scratchPad.buffer;
823 
824  if ( numUsed > 0 )
825  memcpy(newBuffer, m_scratchPad.buffer, numUsed);
826 
827  m_scratchPad.m_allocator.deallocateBytes(m_scratchPad.buffer);
828 
829  /* Update buffer pointers for active allocations */
830  for (size_t i = 0; i < m_scratchPad.m_activeAllocations.size(); ++i)
831  {
832  Container *container = m_scratchPad.m_activeAllocations[i];
833 
834  if (container->m_buffer)
835  {
836  ptrdiff_t offset = (char *)container->m_buffer - (char *)m_scratchPad.buffer;
837  container->m_buffer = newBuffer + offset;
838  }
839  }
840 
841  m_scratchPad.buffer = newBuffer;
842  m_scratchPad.end = m_scratchPad.buffer + newSize;
843  m_scratchPad.head = m_scratchPad.buffer + numUsed;
844  }
845 
846  void *mem = m_scratchPad.head;
847  m_scratchPad.head += numBytes;
848 
849  return mem;
850  }
851 
852  AGX_FORCE_INLINE void Thread::deallocateScratchPadBuffer(void *buffer, size_t numBytes)
853  {
854  agxAssert(!buffer || (buffer >= m_scratchPad.buffer && buffer < m_scratchPad.end));
855 
856  if ((char *)buffer + numBytes == m_scratchPad.head)
857  m_scratchPad.head = (char *)buffer;
858  }
859 
860  AGX_FORCE_INLINE void Thread::registerContainerAllocation(Container *container)
861  {
862  m_scratchPad.m_activeAllocations.push_back(container);
863  }
864 
865  #ifdef AGX_DEBUG
866  AGX_FORCE_INLINE void Thread::unregisterContainerAllocation(Container *container)
867  #else
868  AGX_FORCE_INLINE void Thread::unregisterContainerAllocation(Container * /* container */)
869  #endif
870  {
871  agxAssert1(!m_scratchPad.m_activeAllocations.empty() && container == m_scratchPad.m_activeAllocations.back(), "LIFO order required!");
872  m_scratchPad.m_activeAllocations.pop_back();
873 
874  /* Reset scratch pad, removing any holes from reallocations */
875  if (m_scratchPad.m_activeAllocations.empty())
876  m_scratchPad.head = m_scratchPad.buffer;
877  }
878 
879 }
880 
881 
882 #if ENABLE_VERBOSE_THREAD_TIMELINE
883  #define AGX_BEGIN_TIMELINE_REPORT(variable) \
884  auto variable ## _begin_time = agx::Timer::getCurrentTick()
885 
886  #define AGX_END_TIMELINE_REPORT(variable, title) \
887  auto variable ## _end_time = agx::Timer::getCurrentTick(); \
888  agx::Thread::getCurrentThread()->reportSystemJob( variable ## _begin_time , variable ## _end_time, title);
889 
890  #define AGX_END_TIMELINE_REPORT_DATA(variable, title, title2, data) \
891  auto variable ## _end_time = agx::Timer::getCurrentTick(); \
892  agx::Thread::getCurrentThread()->reportSystemJob( variable ## _begin_time , variable ## _end_time, title, title2, data)
893 #else
894  #define AGX_BEGIN_TIMELINE_REPORT(variable)
895  #define AGX_END_TIMELINE_REPORT(variable, title)
896  #define AGX_END_TIMELINE_REPORT_DATA(variable, title, title2, data)
897 #endif
898 
899 
900 #ifdef _MSC_VER
901 # pragma warning(pop)
902 #endif
Basic wrapper class aroud std::thread.
Definition: Thread.h:82
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API...
An attribute container.
double Real64
Definition: Real.h:45
void AGXPHYSICS_EXPORT shutdown()
Shutdown of the AGX Dynamics API will be done when the number of shutdown matches the number of calls...
The Container is the base class for several of the container classes proided by AGX, such as agx::Vector and agx::HashSet.
Definition: Container.h:34
agx::Thread is a representation of an OS specific implementation of a computational thread...
Definition: Thread.h:198
ThreadState
States for the thread.
Definition: Thread.h:89
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:72
An abstract job/workblock representation, which allows work threads to execute arbitrary tasks...
Definition: Job.h:62
#define agxAssertN(expr, format,...)
Definition: debug.h:145
#define AGX_MAX_NUM_THREADS
Definition: Thread.h:48
HashTable< Thread *, Index > ThreadIdTable
Definition: Thread.h:387
#define AGXPHYSICS_EXPORT
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
A representation of a generic task.
Definition: Task.h:57
#define AGX_FORCE_INLINE
Definition: Object.h:59
void agxFlushThreadLogs()
void AGXCORE_EXPORT resetStartTick()
Reset the startTick value to the current tick.
Block synchronization primitive.
Base class providing referencing counted objects.
Definition: Referenced.h:119
void * ThreadStorageData
Definition: Thread.h:210
Memory pool.
Definition: MemoryPool.h:26
VectorPOD< class Job * > JobPtrVector
Definition: Job.h:51
agx::VectorPOD< Thread * > ThreadPtrVector
Definition: Thread.h:660
std::atomic< unsigned int > m_state
Definition: Thread.h:187
Vector containing &#39;raw&#39; data.
Definition: Vector.h:245
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
AGXCORE_EXPORT Thread * getCurrentThread()
Class for handling logging of messages.
Definition: Notify.h:63
Contains classes for low level data storage for AGX.
Definition: Container.h:23
UInt32 Index
Definition: Integer.h:52
Byte allocator.
Definition: Allocator.h:56
static bool immediateLogging
Definition: Thread.h:374
#define agxAssert(expr)
Definition: debug.h:143
virtual void run()
This method is invoked by start.
Definition: Thread.h:116
An abstract description of a data entity stored using SOA (structure of arrays) pattern in a EntitySt...
Definition: EntityModel.h:63
pthread_key_t ThreadStorageKey
Definition: Thread.h:209
void * m_buffer
Definition: Container.h:96
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:41
void AGXCORE_EXPORT setNumThreads(size_t numThreads)
Set the number of threads to use (including the main thread).
uint64_t UInt64
Definition: Integer.h:41
std::thread m_handle
Definition: Thread.h:186
Generator of UUID values based on V4 http://en.wikipedia.org/wiki/Universally_unique_identifier.
Definition: Uuid.h:231
#define agxAssert1(expr, msg)
Definition: debug.h:144
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
double Real
Definition: Real.h:42
Inheritance with partial specialization due to bug with ref_ptr containers.
Spin-lock mutex.
Definition: SpinMutex.h:46
uint32_t UInt32
Definition: Integer.h:40
#define AGX_THREAD_FRAME_STACK_MAX_DEPTH
Definition: Thread.h:481
#define AGXCORE_EXPORT
std::mt19937 RandomGenerator
Definition: Thread.h:213