3 //=============================================================================
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)
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"
24 #include "ace/Atomic_Op.h"
26 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
28 class TAO_RTScheduler_Current_i
;
29 class TAO_TSS_Resources
;
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
44 /// Returns hash value.
45 u_long
operator () (const IdType
&id
) const;
48 typedef ACE_Hash_Map_Manager_Ex
<IdType
,
49 RTScheduling::DistributableThread_var
,
55 typedef ACE_Hash_Map_Iterator_Ex
<IdType
,
56 RTScheduling::DistributableThread_var
,
62 typedef ACE_Hash_Map_Entry
<IdType
,
63 RTScheduling::DistributableThread_var
>
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
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
91 CORBA::Policy_ptr sched_param
,
92 CORBA::Policy_ptr implicit_sched_param
) override
;
94 void update_scheduling_segment
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
,
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
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 ()
149 const char* _interface_repository_id () const override
;
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
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 *);
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
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
,
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
,
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
225 CORBA::Policy_ptr sched_param
,
226 CORBA::Policy_ptr implicit_sched_param
);
228 virtual void update_scheduling_segment
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 ();
255 void cleanup_current ();
257 void delete_all_currents ();
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
);
272 RTScheduling::Scheduler_var scheduler_
;
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
>
287 DTTask (TAO_ORB_Core
* orb
,
289 TAO_RTScheduler_Current_i
*,
290 RTScheduling::ThreadAction_ptr start
,
291 CORBA::VoidData data
,
293 CORBA::Policy_ptr sched_param
,
294 CORBA::Policy_ptr implicit_sched_param
);
298 int activate_task (RTCORBA::Priority base_priority
,
299 CORBA::ULong stack_size
);
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*/