00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef TAO_RTSCHEDULER_CURRENT_H
00015 #define TAO_RTSCHEDULER_CURRENT_H
00016
00017 #include "ace/pre.h"
00018
00019 #include "tao/RTScheduling/rtscheduler_export.h"
00020
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif
00024
00025 #include "tao/RTScheduling/RTScheduler.h"
00026 #include "tao/LocalObject.h"
00027 #include "ace/Hash_Map_Manager_T.h"
00028 #include "ace/Task.h"
00029 #include "ace/Atomic_Op.h"
00030
00031 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00032
00033 class TAO_RTScheduler_Current_i;
00034 class TAO_TSS_Resources;
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 typedef TAO::unbounded_value_sequence<CORBA::Octet> IdType;
00045
00046 class TAO_RTScheduler_Export TAO_DTId_Hash
00047 {
00048 public:
00049
00050
00051 u_long operator () (const IdType &id) const;
00052 };
00053
00054
00055 typedef ACE_Hash_Map_Manager_Ex<IdType,
00056 RTScheduling::DistributableThread_var,
00057 TAO_DTId_Hash,
00058 ACE_Equal_To<IdType>,
00059 TAO_SYNCH_MUTEX>
00060 DT_Hash_Map;
00061
00062 typedef ACE_Hash_Map_Iterator_Ex<IdType,
00063 RTScheduling::DistributableThread_var,
00064 TAO_DTId_Hash,
00065 ACE_Equal_To<IdType>,
00066 TAO_SYNCH_MUTEX>
00067 DT_Hash_Map_Iterator;
00068
00069 typedef ACE_Hash_Map_Entry<IdType,
00070 RTScheduling::DistributableThread_var>
00071 DT_Hash_Map_Entry;
00072
00073 class TAO_RTScheduler_Current;
00074 class TAO_RTScheduler_Current_var;
00075
00076 typedef TAO_RTScheduler_Current* TAO_RTScheduler_Current_ptr;
00077
00078 class TAO_RTScheduler_Export TAO_RTScheduler_Current
00079 : public RTScheduling::Current,
00080 public ::CORBA::LocalObject
00081 {
00082 public:
00083 static ACE_Atomic_Op<TAO_SYNCH_MUTEX, long> guid_counter;
00084
00085 TAO_RTScheduler_Current (void);
00086 virtual ~TAO_RTScheduler_Current (void);
00087
00088 void init (TAO_ORB_Core* orb);
00089
00090 virtual RTCORBA::Priority the_priority (void);
00091
00092 virtual void the_priority (RTCORBA::Priority the_priority);
00093
00094 void rt_current (RTCORBA::Current_ptr rt_current);
00095
00096 virtual void begin_scheduling_segment
00097 (const char * name,
00098 CORBA::Policy_ptr sched_param,
00099 CORBA::Policy_ptr implicit_sched_param);
00100
00101 virtual void update_scheduling_segment
00102 (const char * name,
00103 CORBA::Policy_ptr sched_param,
00104 CORBA::Policy_ptr implicit_sched_param);
00105
00106 virtual void end_scheduling_segment (const char * name);
00107
00108 virtual RTScheduling::DistributableThread_ptr
00109 lookup(const RTScheduling::Current::IdType & id);
00110
00111
00112
00113
00114
00115 virtual RTScheduling::DistributableThread_ptr
00116 spawn (RTScheduling::ThreadAction_ptr start,
00117 CORBA::VoidData data,
00118 const char* name,
00119 CORBA::Policy_ptr sched_param,
00120 CORBA::Policy_ptr implicit_sched_param,
00121 CORBA::ULong stack_size,
00122 RTCORBA::Priority base_priority);
00123
00124 virtual ::RTScheduling::Current::IdType *id (void);
00125
00126 virtual ::CORBA::Policy_ptr scheduling_parameter (void);
00127
00128 virtual ::CORBA::Policy_ptr implicit_scheduling_parameter (void);
00129
00130 virtual ::RTScheduling::Current::NameList *
00131 current_scheduling_segment_names (void);
00132
00133 TAO_RTScheduler_Current_i* implementation (void);
00134
00135 TAO_RTScheduler_Current_i* implementation (TAO_RTScheduler_Current_i*);
00136
00137 TAO_ORB_Core* orb (void);
00138
00139 DT_Hash_Map* dt_hash (void);
00140
00141
00142
00143
00144
00145 typedef TAO_RTScheduler_Current_ptr _ptr_type;
00146 typedef TAO_RTScheduler_Current_var _var_type;
00147
00148 static TAO_RTScheduler_Current_ptr _duplicate (TAO_RTScheduler_Current_ptr obj);
00149
00150 static TAO_RTScheduler_Current_ptr _narrow (
00151 CORBA::Object_ptr obj
00152 );
00153
00154
00155 static TAO_RTScheduler_Current_ptr _nil (void)
00156 {
00157 return (TAO_RTScheduler_Current_ptr)0;
00158 }
00159
00160 virtual const char* _interface_repository_id (void) const;
00161
00162
00163 private:
00164 RTCORBA::Current_var rt_current_;
00165 TAO_ORB_Core* orb_;
00166 DT_Hash_Map dt_hash_;
00167
00168 };
00169
00170
00171
00172
00173
00174
00175 class TAO_RTScheduler_Export TAO_RTScheduler_Current_var
00176 : private TAO_Base_var
00177 {
00178 public:
00179
00180 TAO_RTScheduler_Current_var (void);
00181 TAO_RTScheduler_Current_var (TAO_RTScheduler_Current_ptr p) : ptr_ (p) {}
00182 TAO_RTScheduler_Current_var (const TAO_RTScheduler_Current_var &);
00183 ~TAO_RTScheduler_Current_var (void);
00184
00185 TAO_RTScheduler_Current_var &operator= (TAO_RTScheduler_Current_ptr);
00186 TAO_RTScheduler_Current_var &operator= (const TAO_RTScheduler_Current_var &);
00187 TAO_RTScheduler_Current_ptr operator-> (void) const;
00188
00189 operator const TAO_RTScheduler_Current_ptr &() const;
00190 operator TAO_RTScheduler_Current_ptr &();
00191
00192 TAO_RTScheduler_Current_ptr in (void) const;
00193 TAO_RTScheduler_Current_ptr &inout (void);
00194 TAO_RTScheduler_Current_ptr &out (void);
00195 TAO_RTScheduler_Current_ptr _retn (void);
00196 TAO_RTScheduler_Current_ptr ptr (void) const;
00197
00198
00199
00200 static TAO_RTScheduler_Current_ptr duplicate (TAO_RTScheduler_Current_ptr);
00201 static void release (TAO_RTScheduler_Current_ptr);
00202 static TAO_RTScheduler_Current_ptr nil (void);
00203 static TAO_RTScheduler_Current_ptr narrow (
00204 CORBA::Object *
00205
00206 );
00207 static CORBA::Object * upcast (void *);
00208
00209 private:
00210
00211 TAO_RTScheduler_Current_ptr ptr_;
00212
00213 TAO_RTScheduler_Current_var (const TAO_Base_var &rhs);
00214 TAO_RTScheduler_Current_var &operator= (const TAO_Base_var &rhs);
00215
00216 };
00217
00218
00219 class TAO_RTScheduler_Export TAO_RTScheduler_Current_i
00220 {
00221 public:
00222
00223 TAO_RTScheduler_Current_i (TAO_ORB_Core* orb,
00224 DT_Hash_Map* dt_hash);
00225
00226 TAO_RTScheduler_Current_i (TAO_ORB_Core* orb,
00227 DT_Hash_Map* dt_hash,
00228 RTScheduling::Current::IdType guid,
00229 const char * name,
00230 CORBA::Policy_ptr sched_param,
00231 CORBA::Policy_ptr implicit_sched_param,
00232 RTScheduling::DistributableThread_ptr dt,
00233 TAO_RTScheduler_Current_i* prev_current);
00234
00235 virtual ~TAO_RTScheduler_Current_i (void);
00236
00237 virtual RTScheduling::DistributableThread_ptr
00238 spawn (RTScheduling::ThreadAction_ptr start,
00239 CORBA::VoidData data,
00240 const char* name,
00241 CORBA::Policy_ptr sched_param,
00242 CORBA::Policy_ptr implicit_sched_param,
00243 CORBA::ULong stack_size,
00244 RTCORBA::Priority base_priority);
00245
00246 virtual void begin_scheduling_segment
00247 (const char * name,
00248 CORBA::Policy_ptr sched_param,
00249 CORBA::Policy_ptr implicit_sched_param);
00250
00251 virtual void update_scheduling_segment
00252 (const char * name,
00253 CORBA::Policy_ptr sched_param,
00254 CORBA::Policy_ptr implicit_sched_param);
00255
00256 virtual void end_scheduling_segment (const char * name);
00257
00258 virtual RTScheduling::Current::IdType *id (void);
00259
00260
00261 void id (RTScheduling::Current::IdType guid);
00262
00263 virtual CORBA::Policy_ptr scheduling_parameter (void);
00264
00265 virtual CORBA::Policy_ptr implicit_scheduling_parameter (void);
00266
00267 void scheduling_parameter (CORBA::Policy_ptr);
00268
00269 void implicit_scheduling_parameter (CORBA::Policy_ptr);
00270
00271 virtual RTScheduling::Current::NameList *
00272 current_scheduling_segment_names (void);
00273
00274 void cancel_thread (void);
00275
00276 void cleanup_DT (void);
00277
00278 void cleanup_current (void);
00279
00280 void delete_all_currents (void);
00281
00282 const char* name (void);
00283 void name (const char *);
00284
00285 TAO_ORB_Core* orb (void);
00286
00287 RTScheduling::Scheduler_ptr scheduler (void);
00288
00289 DT_Hash_Map* dt_hash (void);
00290
00291 RTScheduling::DistributableThread_ptr DT (void);
00292 void DT (RTScheduling::DistributableThread_ptr);
00293
00294 private:
00295 RTScheduling::Scheduler_var scheduler_;
00296 TAO_ORB_Core* orb_;
00297 RTScheduling::Current::IdType guid_;
00298 CORBA::String_var name_;
00299 CORBA::Policy_var sched_param_;
00300 CORBA::Policy_var implicit_sched_param_;
00301 RTScheduling::DistributableThread_var dt_;
00302 TAO_RTScheduler_Current_i* previous_current_;
00303 DT_Hash_Map* dt_hash_;
00304 };
00305
00306
00307 class DTTask : public ACE_Task <ACE_SYNCH>
00308 {
00309 public:
00310 DTTask (TAO_ORB_Core* orb,
00311 DT_Hash_Map* dt_hash,
00312 TAO_RTScheduler_Current_i*,
00313 RTScheduling::ThreadAction_ptr start,
00314 CORBA::VoidData data,
00315 const char* name,
00316 CORBA::Policy_ptr sched_param,
00317 CORBA::Policy_ptr implicit_sched_param);
00318
00319 virtual ~DTTask (void);
00320
00321 int activate_task (RTCORBA::Priority base_priority,
00322 CORBA::ULong stack_size);
00323
00324 virtual int svc (void);
00325
00326 private:
00327 TAO_ORB_Core* orb_;
00328 DT_Hash_Map* dt_hash_;
00329 TAO_RTScheduler_Current_i* current_;
00330 RTScheduling::ThreadAction_var start_;
00331 CORBA::VoidData data_;
00332 RTScheduling::Current::IdType guid_;
00333 CORBA::String_var name_;
00334 CORBA::Policy_var sched_param_;
00335 CORBA::Policy_var implicit_sched_param_;
00336 };
00337
00338 TAO_END_VERSIONED_NAMESPACE_DECL
00339
00340 #include "ace/post.h"
00341
00342 #endif