space_multi_thread_balance_length.h
Go to the documentation of this file.
1 
11 #ifndef SPACE_MULTI_THREAD_BALANCE_LENGTH_H
12 #define SPACE_MULTI_THREAD_BALANCE_LENGTH_H
13 
14 namespace argos {
15  class CSpace;
16 }
17 
18 #include <argos3/core/simulator/space/space.h>
19 
20 namespace argos {
21 
23 
24  public:
25 
28 
29  virtual void Init(TConfigurationNode& t_tree);
30  virtual void Destroy();
31 
32  virtual void Update();
33  virtual void UpdateControllableEntitiesAct();
34  virtual void UpdatePhysics();
35  virtual void UpdateMedia();
38  const TControllableEntityIterCBType& c_cb);
39 
40  private:
41 
42  void StartThreads();
43  void SlaveThread();
44  friend void* LaunchThreadBalanceLength(void* p_data);
45 
46  private:
47 
49  struct SThreadLaunchData {
50  UInt32 ThreadId;
52 
53  SThreadLaunchData(UInt32 un_thread_id,
55  ThreadId(un_thread_id),
56  Space(pc_space) {}
57  };
58 
60  pthread_t* m_ptThreads;
61 
63  SThreadLaunchData** m_psThreadData;
64 
66  size_t m_unTaskIndex;
67 
69  pthread_mutex_t m_tStartSenseControlPhaseMutex;
71  pthread_mutex_t m_tStartActPhaseMutex;
73  pthread_mutex_t m_tStartPhysicsPhaseMutex;
75  pthread_mutex_t m_tStartMediaPhaseMutex;
77  pthread_mutex_t m_tStartEntityIterPhaseMutex;
79  pthread_mutex_t m_tFetchTaskMutex;
80 
82  pthread_cond_t m_tStartSenseControlPhaseCond;
84  pthread_cond_t m_tStartActPhaseCond;
86  pthread_cond_t m_tStartPhysicsPhaseCond;
88  pthread_cond_t m_tStartMediaPhaseCond;
90  pthread_cond_t m_tStartEntityIterPhaseCond;
92  pthread_cond_t m_tFetchTaskCond;
93 
95  UInt32 m_unSenseControlPhaseIdleCounter;
97  UInt32 m_unActPhaseIdleCounter;
99  UInt32 m_unPhysicsPhaseIdleCounter;
101  UInt32 m_unMediaPhaseIdleCounter;
103  UInt32 m_unEntityIterPhaseIdleCounter;
104 
105  };
106 
107 }
108 
109 #endif
unsigned int UInt32
32-bit unsigned integer.
Definition: datatypes.h:97
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
std::function< void(CControllableEntity *)> TControllableEntityIterCBType
The callback type for iteration over controllable entities within the PreStep() and/or PostStep() par...
Definition: space.h:90
virtual void IterateOverControllableEntities(const TControllableEntityIterCBType &c_cb)
Given a callback specified in the loop functions, iterate over all controllable entities currently pr...
virtual void Destroy()
Destroys the space and all its entities.
virtual void Init(TConfigurationNode &t_tree)
Initializes the space using the <arena> section of the XML configuration file.