Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / RTScheduling / Current.h
blob9869380f4bc92b85364bbb394ee71b35eeb8b2ab
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Current.h
6 */
7 //=============================================================================
9 #ifndef TAO_RTSCHEDULER_CURRENT_H
10 #define TAO_RTSCHEDULER_CURRENT_H
12 #include /**/ "ace/pre.h"
14 #include "tao/RTScheduling/rtscheduler_export.h"
16 #if !defined (ACE_LACKS_PRAGMA_ONCE)
17 # pragma once
18 #endif /* ACE_LACKS_PRAGMA_ONCE */
20 #include "tao/RTScheduling/RTScheduler.h"
21 #include "tao/LocalObject.h"
22 #include "ace/Hash_Map_Manager_T.h"
23 #include "ace/Task.h"
24 #include "ace/Atomic_Op.h"
26 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
28 class TAO_RTScheduler_Current_i;
29 class TAO_TSS_Resources;
31 /**
32 * @class TAO_DTId_Hash
34 * @brief Hashing class for Distributable Thread Ids.
36 * Define the hash() method for Object Ids.
39 typedef TAO::unbounded_value_sequence<CORBA::Octet> IdType;
41 class TAO_RTScheduler_Export TAO_DTId_Hash
43 public:
44 /// Returns hash value.
45 u_long operator () (const IdType &id) const;
48 typedef ACE_Hash_Map_Manager_Ex<IdType,
49 RTScheduling::DistributableThread_var,
50 TAO_DTId_Hash,
51 ACE_Equal_To<IdType>,
52 TAO_SYNCH_MUTEX>
53 DT_Hash_Map;
55 typedef ACE_Hash_Map_Iterator_Ex<IdType,
56 RTScheduling::DistributableThread_var,
57 TAO_DTId_Hash,
58 ACE_Equal_To<IdType>,
59 TAO_SYNCH_MUTEX>
60 DT_Hash_Map_Iterator;
62 typedef ACE_Hash_Map_Entry<IdType,
63 RTScheduling::DistributableThread_var>
64 DT_Hash_Map_Entry;
66 class TAO_RTScheduler_Current;
67 class TAO_RTScheduler_Current_var;
69 typedef TAO_RTScheduler_Current* TAO_RTScheduler_Current_ptr;
71 class TAO_RTScheduler_Export TAO_RTScheduler_Current
72 : public RTScheduling::Current,
73 public ::CORBA::LocalObject
75 public:
76 static std::atomic<long> guid_counter;
78 TAO_RTScheduler_Current () = default;
79 virtual ~TAO_RTScheduler_Current ();
81 void init (TAO_ORB_Core* orb);
83 RTCORBA::Priority the_priority () override;
85 void the_priority (RTCORBA::Priority the_priority) override;
87 void rt_current (RTCORBA::Current_ptr rt_current);
89 void begin_scheduling_segment
90 (const char * name,
91 CORBA::Policy_ptr sched_param,
92 CORBA::Policy_ptr implicit_sched_param) override;
94 void update_scheduling_segment
95 (const char * name,
96 CORBA::Policy_ptr sched_param,
97 CORBA::Policy_ptr implicit_sched_param) override;
99 void end_scheduling_segment (const char * name) override;
101 RTScheduling::DistributableThread_ptr
102 lookup(const RTScheduling::Current::IdType & id) override;
104 // returns a null reference if
105 // the distributable thread is
106 // not known to the local scheduler
107 RTScheduling::DistributableThread_ptr
108 spawn (RTScheduling::ThreadAction_ptr start,
109 CORBA::VoidData data,
110 const char* name,
111 CORBA::Policy_ptr sched_param,
112 CORBA::Policy_ptr implicit_sched_param,
113 CORBA::ULong stack_size,
114 RTCORBA::Priority base_priority) override;
116 ::RTScheduling::Current::IdType *id () override;
118 ::CORBA::Policy_ptr scheduling_parameter () override;
120 ::CORBA::Policy_ptr implicit_scheduling_parameter () override;
122 ::RTScheduling::Current::NameList *
123 current_scheduling_segment_names () override;
125 TAO_RTScheduler_Current_i* implementation ();
127 TAO_RTScheduler_Current_i* implementation (TAO_RTScheduler_Current_i*);
129 TAO_ORB_Core* orb ();
131 DT_Hash_Map* dt_hash ();
134 * @name Reference Related Methods
136 //@{
137 typedef TAO_RTScheduler_Current_ptr _ptr_type;
138 typedef TAO_RTScheduler_Current_var _var_type;
140 static TAO_RTScheduler_Current_ptr _duplicate (TAO_RTScheduler_Current_ptr obj);
142 static TAO_RTScheduler_Current_ptr _narrow (CORBA::Object_ptr obj);
144 static TAO_RTScheduler_Current_ptr _nil ()
146 return nullptr;
149 const char* _interface_repository_id () const override;
150 //@}
152 private:
153 RTCORBA::Current_var rt_current_;
154 TAO_ORB_Core* orb_ {};
155 DT_Hash_Map dt_hash_;
159 * @class TAO_RTScheduler_Current_var
161 class TAO_RTScheduler_Export TAO_RTScheduler_Current_var
162 : private TAO_Base_var
164 public:
165 TAO_RTScheduler_Current_var (); // default constructor
166 TAO_RTScheduler_Current_var (TAO_RTScheduler_Current_ptr p) : ptr_ (p) {}
167 TAO_RTScheduler_Current_var (const TAO_RTScheduler_Current_var &); // copy constructor
168 ~TAO_RTScheduler_Current_var (); // destructor
170 TAO_RTScheduler_Current_var &operator= (TAO_RTScheduler_Current_ptr);
171 TAO_RTScheduler_Current_var &operator= (const TAO_RTScheduler_Current_var &);
172 TAO_RTScheduler_Current_ptr operator-> () const;
174 operator const TAO_RTScheduler_Current_ptr &() const;
175 operator TAO_RTScheduler_Current_ptr &();
176 // in, inout, out, _retn
177 TAO_RTScheduler_Current_ptr in () const;
178 TAO_RTScheduler_Current_ptr &inout ();
179 TAO_RTScheduler_Current_ptr &out ();
180 TAO_RTScheduler_Current_ptr _retn ();
181 TAO_RTScheduler_Current_ptr ptr () const;
183 // Hooks used by template sequence and object manager classes
184 // for non-defined forward declared interfaces.
185 static TAO_RTScheduler_Current_ptr duplicate (TAO_RTScheduler_Current_ptr);
186 static void release (TAO_RTScheduler_Current_ptr);
187 static TAO_RTScheduler_Current_ptr nil ();
188 static TAO_RTScheduler_Current_ptr narrow (CORBA::Object *);
189 static CORBA::Object * upcast (void *);
191 private:
192 TAO_RTScheduler_Current_ptr ptr_;
193 TAO_RTScheduler_Current_var (const TAO_Base_var &rhs) = delete;
194 TAO_RTScheduler_Current_var &operator= (const TAO_Base_var &rhs) = delete;
197 class TAO_RTScheduler_Export TAO_RTScheduler_Current_i
199 public:
200 TAO_RTScheduler_Current_i (TAO_ORB_Core* orb,
201 DT_Hash_Map* dt_hash);
203 TAO_RTScheduler_Current_i (TAO_ORB_Core* orb,
204 DT_Hash_Map* dt_hash,
205 RTScheduling::Current::IdType guid,
206 const char * name,
207 CORBA::Policy_ptr sched_param,
208 CORBA::Policy_ptr implicit_sched_param,
209 RTScheduling::DistributableThread_ptr dt,
210 TAO_RTScheduler_Current_i* prev_current);
212 virtual ~TAO_RTScheduler_Current_i ();
214 virtual RTScheduling::DistributableThread_ptr
215 spawn (RTScheduling::ThreadAction_ptr start,
216 CORBA::VoidData data,
217 const char* name,
218 CORBA::Policy_ptr sched_param,
219 CORBA::Policy_ptr implicit_sched_param,
220 CORBA::ULong stack_size,
221 RTCORBA::Priority base_priority);
223 virtual void begin_scheduling_segment
224 (const char * name,
225 CORBA::Policy_ptr sched_param,
226 CORBA::Policy_ptr implicit_sched_param);
228 virtual void update_scheduling_segment
229 (const char * name,
230 CORBA::Policy_ptr sched_param,
231 CORBA::Policy_ptr implicit_sched_param);
233 virtual void end_scheduling_segment (const char * name);
235 virtual RTScheduling::Current::IdType *id ();
238 void id (RTScheduling::Current::IdType guid);
240 virtual CORBA::Policy_ptr scheduling_parameter ();
242 virtual CORBA::Policy_ptr implicit_scheduling_parameter ();
244 void scheduling_parameter (CORBA::Policy_ptr);
246 void implicit_scheduling_parameter (CORBA::Policy_ptr);
248 virtual RTScheduling::Current::NameList *
249 current_scheduling_segment_names ();
251 void cancel_thread ();
253 void cleanup_DT ();
255 void cleanup_current ();
257 void delete_all_currents ();
259 const char* name ();
260 void name (const char *);
262 TAO_ORB_Core* orb ();
264 RTScheduling::Scheduler_ptr scheduler ();
266 DT_Hash_Map* dt_hash ();
268 RTScheduling::DistributableThread_ptr DT ();
269 void DT (RTScheduling::DistributableThread_ptr);
271 private:
272 RTScheduling::Scheduler_var scheduler_;
273 TAO_ORB_Core* orb_;
274 RTScheduling::Current::IdType guid_;
275 CORBA::String_var name_;
276 CORBA::Policy_var sched_param_;
277 CORBA::Policy_var implicit_sched_param_;
278 RTScheduling::DistributableThread_var dt_;
279 TAO_RTScheduler_Current_i* previous_current_;
280 DT_Hash_Map* dt_hash_;
283 // This class provides an entry point for the// new DT.
284 class DTTask : public ACE_Task <ACE_SYNCH>
286 public:
287 DTTask (TAO_ORB_Core* orb,
288 DT_Hash_Map* ,
289 TAO_RTScheduler_Current_i*,
290 RTScheduling::ThreadAction_ptr start,
291 CORBA::VoidData data,
292 const char* name,
293 CORBA::Policy_ptr sched_param,
294 CORBA::Policy_ptr implicit_sched_param);
296 virtual ~DTTask ();
298 int activate_task (RTCORBA::Priority base_priority,
299 CORBA::ULong stack_size);
301 int svc () override;
303 private:
304 TAO_ORB_Core* orb_;
305 TAO_RTScheduler_Current_i* current_;
306 RTScheduling::ThreadAction_var start_;
307 CORBA::VoidData data_;
308 RTScheduling::Current::IdType guid_;
309 CORBA::String_var name_;
310 CORBA::Policy_var sched_param_;
311 CORBA::Policy_var implicit_sched_param_;
314 TAO_END_VERSIONED_NAMESPACE_DECL
316 #include /**/ "ace/post.h"
318 #endif /* TAO_RTSCHEDULER_CURRENT_H*/