📄 current.cpp
字号:
//Current.cpp,v 1.15 2003/11/04 05:21:38 dhinton Exp
#include "Current.h"
#include "Distributable_Thread.h"
#include "tao/RTCORBA/Priority_Mapping_Manager.h"
#include "tao/RTCORBA/RT_Current.h"
#include "tao/ORB_Core.h"
#include "tao/TSS_Resources.h"
#include "ace/ACE.h"
#include "ace/OS_NS_errno.h"
ACE_RCSID (RTScheduling,
Current,
"Current.cpp,v 1.15 2003/11/04 05:21:38 dhinton Exp")
ACE_Atomic_Op<TAO_SYNCH_MUTEX, long> TAO_RTScheduler_Current::guid_counter;
u_long
TAO_DTId_Hash::operator () (const IdType &id) const
{
return ACE::hash_pjw ((const char *) id.get_buffer (),
id.length ());
}
TAO_RTScheduler_Current::TAO_RTScheduler_Current (void)
{
}
void
TAO_RTScheduler_Current::init (TAO_ORB_Core* orb
ACE_ENV_ARG_DECL)
{
this->orb_ = orb;
// Create the RT_Current.
RTCORBA::Current_ptr current;
ACE_NEW_THROW_EX (current,
TAO_RT_Current (orb),
CORBA::NO_MEMORY (
CORBA::SystemException::_tao_minor_code (
TAO_DEFAULT_MINOR_CODE,
ENOMEM),
CORBA::COMPLETED_NO));
this->rt_current_ = current;
}
void
TAO_RTScheduler_Current::rt_current (RTCORBA::Current_ptr rt_current)
{
this->rt_current_ = RTCORBA::Current::_duplicate (rt_current);
}
TAO_ORB_Core*
TAO_RTScheduler_Current::orb (void)
{
return this->orb_;
}
DT_Hash_Map*
TAO_RTScheduler_Current::dt_hash (void)
{
return &this->dt_hash_;
}
void
TAO_RTScheduler_Current::begin_scheduling_segment(const char * name,
CORBA::Policy_ptr sched_param,
CORBA::Policy_ptr implicit_sched_param
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RTScheduling::Current::UNSUPPORTED_SCHEDULING_DISCIPLINE))
{
TAO_RTScheduler_Current_i *impl = this->implementation ();
if (impl == 0)
{
ACE_NEW_THROW_EX (impl,
TAO_RTScheduler_Current_i (this->orb_,
&this->dt_hash_),
CORBA::NO_MEMORY (
CORBA::SystemException::_tao_minor_code (
TAO_DEFAULT_MINOR_CODE,
ENOMEM),
CORBA::COMPLETED_NO));
ACE_CHECK;
this->implementation (impl);
}
impl->begin_scheduling_segment (name,
sched_param,
implicit_sched_param
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
void
TAO_RTScheduler_Current::update_scheduling_segment (const char * name,
CORBA::Policy_ptr sched_param,
CORBA::Policy_ptr implicit_sched_param
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
RTScheduling::Current::UNSUPPORTED_SCHEDULING_DISCIPLINE))
{
TAO_RTScheduler_Current_i *impl = this->implementation ();
if (impl == 0)
ACE_THROW (CORBA::BAD_INV_ORDER ());
impl->update_scheduling_segment (name,
sched_param,
implicit_sched_param
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
void
TAO_RTScheduler_Current::end_scheduling_segment (const char * name
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_RTScheduler_Current_i *impl = this->implementation ();
if (impl == 0)
{
ACE_ERROR ((LM_ERROR,
"Missing scheduling context OR DT cancelled\n"));
ACE_THROW (CORBA::BAD_INV_ORDER ());
return;
}
impl->end_scheduling_segment (name
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
RTScheduling::DistributableThread_ptr
TAO_RTScheduler_Current::lookup(const RTScheduling::Current::IdType & id
ACE_ENV_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException))
{
RTScheduling::DistributableThread_var DT;
int result = this->dt_hash_.find (id,
DT);
if (result == 0)
return DT._retn ();
else return RTScheduling::DistributableThread::_nil ();
}
// returns a null reference if
// the distributable thread is
// not known to the local scheduler
RTScheduling::DistributableThread_ptr
TAO_RTScheduler_Current::spawn (RTScheduling::ThreadAction_ptr start,
CORBA::VoidData data,
const char* name,
CORBA::Policy_ptr sched_param,
CORBA::Policy_ptr implicit_sched_param,
CORBA::ULong stack_size,
RTCORBA::Priority base_priority
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_RTScheduler_Current_i *impl = this->implementation ();
if (impl == 0)
ACE_THROW_RETURN (CORBA::BAD_INV_ORDER (), 0);
return impl->spawn (start,
data,
name,
sched_param,
implicit_sched_param,
stack_size,
base_priority
ACE_ENV_ARG_PARAMETER);
}
RTScheduling::Current::IdType *
TAO_RTScheduler_Current::id (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_RTScheduler_Current_i *impl = this->implementation ();
if (impl == 0)
ACE_THROW_RETURN (CORBA::BAD_INV_ORDER (), 0);
return impl->id (ACE_ENV_SINGLE_ARG_PARAMETER);
}
CORBA::Policy_ptr
TAO_RTScheduler_Current::scheduling_parameter (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_RTScheduler_Current_i *impl = this->implementation ();
if (impl == 0)
ACE_THROW_RETURN (CORBA::BAD_INV_ORDER (), 0);
return impl->scheduling_parameter (ACE_ENV_SINGLE_ARG_PARAMETER);
}
CORBA::Policy_ptr
TAO_RTScheduler_Current::implicit_scheduling_parameter (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_RTScheduler_Current_i *impl = this->implementation ();
if (impl == 0)
ACE_THROW_RETURN (CORBA::BAD_INV_ORDER (), 0);
return impl->implicit_scheduling_parameter (ACE_ENV_SINGLE_ARG_PARAMETER);
}
RTScheduling::Current::NameList *
TAO_RTScheduler_Current::current_scheduling_segment_names (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_RTScheduler_Current_i *impl = this->implementation ();
if (impl == 0)
ACE_THROW_RETURN (CORBA::BAD_INV_ORDER (), 0);
return impl->current_scheduling_segment_names (ACE_ENV_SINGLE_ARG_PARAMETER);
}
RTCORBA::Priority
TAO_RTScheduler_Current::the_priority (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
return this->rt_current_->the_priority (ACE_ENV_SINGLE_ARG_PARAMETER);
}
void
TAO_RTScheduler_Current::the_priority (RTCORBA::Priority the_priority
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
this->rt_current_->the_priority(the_priority
ACE_ENV_ARG_PARAMETER);
}
TAO_RTScheduler_Current_i*
TAO_RTScheduler_Current::implementation (TAO_RTScheduler_Current_i* new_current)
{
TAO_TSS_Resources *tss =
TAO_TSS_RESOURCES::instance ();
TAO_RTScheduler_Current_i *old =
ACE_static_cast (TAO_RTScheduler_Current_i *,
tss->rtscheduler_current_impl_);
tss->rtscheduler_current_impl_ = new_current;
return old;
}
TAO_RTScheduler_Current_i*
TAO_RTScheduler_Current::implementation (void)
{
TAO_TSS_Resources *tss =
TAO_TSS_RESOURCES::instance ();
TAO_RTScheduler_Current_i* impl =
ACE_static_cast (TAO_RTScheduler_Current_i *,
tss->rtscheduler_current_impl_);
return impl;
}
TAO_ORB_Core*
TAO_RTScheduler_Current_i::orb (void)
{
return this->orb_;
}
DT_Hash_Map*
TAO_RTScheduler_Current_i::dt_hash (void)
{
return this->dt_hash_;
}
RTScheduling::Scheduler_ptr
TAO_RTScheduler_Current_i::scheduler (void)
{
return RTScheduling::Scheduler::_duplicate (this->scheduler_.in ());
}
TAO_RTScheduler_Current_i::TAO_RTScheduler_Current_i (TAO_ORB_Core* orb,
DT_Hash_Map* dt_hash
ACE_ENV_ARG_DECL)
:orb_ (orb),
dt_ (RTScheduling::DistributableThread::_nil ()),
previous_current_ (0),
dt_hash_ (dt_hash)
{
CORBA::Object_ptr scheduler_obj =
this->orb_->object_ref_table ().resolve_initial_references (
"RTScheduler"
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
this->scheduler_ = RTScheduling::Scheduler::_narrow (scheduler_obj
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
TAO_RTScheduler_Current_i::TAO_RTScheduler_Current_i (
TAO_ORB_Core* orb,
DT_Hash_Map* dt_hash,
RTScheduling::Current::IdType guid,
const char * name,
CORBA::Policy_ptr sched_param,
CORBA::Policy_ptr implicit_sched_param,
RTScheduling::DistributableThread_ptr dt,
TAO_RTScheduler_Current_i* prev_current
ACE_ENV_ARG_DECL)
: orb_ (orb),
guid_ (guid),
name_ (CORBA::string_dup (name)),
sched_param_ (sched_param),
implicit_sched_param_ (implicit_sched_param),
dt_ (RTScheduling::DistributableThread::_duplicate (dt)),
previous_current_ (prev_current),
dt_hash_ (dt_hash)
{
CORBA::Object_ptr scheduler_obj =
orb->object_ref_table ().resolve_initial_references (
"RTScheduler"
ACE_ENV_ARG_PARAMETER);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -