iMSTK
Interactive Medical Simulation Toolkit
imstkModule.cpp
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #include "imstkModule.h"
8 #include "imstkLogger.h"
9 
10 #include <thread>
11 
12 namespace imstk
13 {
14 void
15 Module::setSleepDelay(const double ms)
16 {
17  CHECK(ms >= 0.0);
18  m_sleepDelay = ms;
19 }
20 
21 void
22 Module::update()
23 {
24  if (m_init && !m_paused)
25  {
26  if (m_sleepDelay != 0.0)
27  {
28  std::this_thread::sleep_for(std::chrono::duration<double, std::milli>(m_sleepDelay));
29  }
30 
31  if (m_muteUpdateEvents)
32  {
33  this->updateModule();
34  }
35  else
36  {
37  this->postEvent(Event(Module::preUpdate()));
38  this->updateModule();
39  this->postEvent(Event(Module::postUpdate()));
40  }
41  }
42 }
43 
44 void
45 Module::uninit()
46 {
47  // Can only uninit if, init'd
48  if (m_init)
49  {
50  uninitModule();
51  m_init = false;
52  }
53 }
54 }// imstk
Compound Geometry.
void postEvent(const T &e)
Emits the event Direct observers will be immediately called, in sync Queued observers will receive th...