space_multi_thread_balance_quantity.h
Go to the documentation of this file.
1 
7 #ifndef SPACE_MULTI_THREAD_BALANCE_QUANTITY_H
8 #define SPACE_MULTI_THREAD_BALANCE_QUANTITY_H
9 
10 #include <argos3/core/simulator/space/space.h>
11 #include <pthread.h>
12 
13 namespace argos {
14 
16 
17  /****************************************/
18  /****************************************/
19 
20  private:
21 
22  struct SUpdateThreadData {
23  UInt32 ThreadId;
25 
26  SUpdateThreadData(UInt32 un_thread_id,
28  ThreadId(un_thread_id),
29  Space(pc_space) {}
30  };
31 
32  /****************************************/
33  /****************************************/
34 
35  private:
36 
38  SUpdateThreadData** m_psUpdateThreadData;
39 
41  pthread_t* m_ptUpdateThreads;
42 
44  UInt32 m_unSenseControlStepPhaseDoneCounter;
45  UInt32 m_unActPhaseDoneCounter;
46  UInt32 m_unPhysicsPhaseDoneCounter;
47  UInt32 m_unMediaPhaseDoneCounter;
48 
50  pthread_mutex_t m_tSenseControlStepConditionalMutex;
51  pthread_mutex_t m_tActConditionalMutex;
52  pthread_mutex_t m_tPhysicsConditionalMutex;
53  pthread_mutex_t m_tMediaConditionalMutex;
54 
56  pthread_cond_t m_tSenseControlStepConditional;
57  pthread_cond_t m_tActConditional;
58  pthread_cond_t m_tPhysicsConditional;
59  pthread_cond_t m_tMediaConditional;
60 
63  bool m_bIsControllableEntityAssignmentRecalculationNeeded;
64 
65  public:
66 
69 
70  virtual void Init(TConfigurationNode& t_tree);
71  virtual void Destroy();
72 
73  virtual void UpdateControllableEntitiesAct();
74  virtual void UpdatePhysics();
75  virtual void UpdateMedia();
77 
78  protected:
79 
80  virtual void AddControllableEntity(CControllableEntity& c_entity);
81  virtual void RemoveControllableEntity(CControllableEntity& c_entity);
82 
83  private:
84 
85  void StartThreads();
86  void UpdateThread(UInt32 un_id);
87  friend void* LaunchUpdateThreadBalanceQuantity(void* p_data);
88 
89  };
90 
91 }
92 
93 #endif
virtual void RemoveControllableEntity(CControllableEntity &c_entity)
An entity that contains a pointer to the user-defined controller.
virtual void AddControllableEntity(CControllableEntity &c_entity)
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
virtual void Destroy()
Destroys the space and all its entities.
unsigned int UInt32
32-bit unsigned integer.
Definition: datatypes.h:97
virtual void Init(TConfigurationNode &t_tree)
Initializes the space using the section of the XML configuration file.
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12