object_adapter.cpp
来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C++ 代码 · 共 2,061 行 · 第 1/5 页
CPP
2,061 行
}
ACE_ENDTRY;
}
void
TAO_Object_Adapter::Servant_Upcall::servant_locator_cleanup (void)
{
#if (TAO_HAS_MINIMUM_POA == 0)
if (this->using_servant_locator_)
{
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
this->poa_->servant_locator_->postinvoke (this->current_context_.object_id (),
this->poa_,
this->operation_,
this->cookie_,
this->servant_
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
// Ignore errors from servant locator ....
}
ACE_ENDTRY;
}
#endif /* TAO_HAS_MINIMUM_POA == 0 */
}
void
TAO_Object_Adapter::Servant_Upcall::single_threaded_poa_setup (ACE_ENV_SINGLE_ARG_DECL)
{
#if (TAO_HAS_MINIMUM_POA == 0)
// Serialize servants (if necessary).
//
// Note that this lock must be acquired *after* the object adapter
// lock has been released. This is necessary since we cannot block
// waiting for the servant lock while holding the object adapter
// lock. Otherwise, the thread that wants to release this lock will
// not be able to do so since it can't acquire the object adapterx
// lock.
if (this->poa_->thread_policy () == PortableServer::SINGLE_THREAD_MODEL)
{
int result = this->poa_->single_threaded_lock ().acquire ();
if (result == -1)
// Locking error.
ACE_THROW (CORBA::OBJ_ADAPTER ());
}
#else
ACE_ENV_ARG_NOT_USED; // FUZZ: ignore check_for_ace_check
#endif /* !TAO_HAS_MINIMUM_POA == 0 */
}
void
TAO_Object_Adapter::Servant_Upcall::single_threaded_poa_cleanup (void)
{
#if (TAO_HAS_MINIMUM_POA == 0)
// Since the servant lock was acquired, we must release it.
if (this->poa_->thread_policy () == PortableServer::SINGLE_THREAD_MODEL)
this->poa_->single_threaded_lock ().release ();
#endif /* TAO_HAS_MINIMUM_POA == 0 */
}
void
TAO_Object_Adapter::Servant_Upcall::servant_cleanup (void)
{
// Cleanup servant related stuff.
if (this->active_object_map_entry_ != 0)
{
// Decrement the reference count.
CORBA::UShort new_count = --this->active_object_map_entry_->reference_count_;
if (new_count == 0)
{
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
this->poa_->cleanup_servant (this->active_object_map_entry_
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
ACE_CATCHALL
{
// Ignore errors from servant cleanup ....
}
ACE_ENDTRY;
if (this->poa_->waiting_servant_deactivation_ > 0 &&
this->object_adapter_->enable_locking_)
{
// Wakeup all waiting threads.
this->poa_->servant_deactivation_condition_.broadcast ();
}
}
}
}
void
TAO_Object_Adapter::Servant_Upcall::poa_cleanup (void)
{
// Decrease <poa->outstanding_requests_> now that the upcall
// is complete.
//
// Note that the object adapter lock is acquired before
// <POA::outstanding_requests_> is decreased.
CORBA::ULong outstanding_requests =
this->poa_->decrement_outstanding_requests ();
// Check if all pending requests are over.
if (outstanding_requests == 0)
{
// If locking is enabled and some thread is waiting in POA::destroy.
if (this->object_adapter_->enable_locking_ &&
this->poa_->wait_for_completion_pending_)
{
// Wakeup all waiting threads.
this->poa_->outstanding_requests_condition_.broadcast ();
}
// Note that there is no need to check for
// <non_servant_upcall_in_progress> since it is not possible for
// non-servant upcalls to be in progress at this point.
if (this->poa_->waiting_destruction_)
{
ACE_TRY_NEW_ENV
{
this->poa_->complete_destruction_i (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
// Ignore exceptions
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "TAO_POA::~complete_destruction_i");
}
ACE_ENDTRY;
this->poa_ = 0;
}
}
}
void
TAO_Object_Adapter::servant_dispatcher (TAO_Servant_Dispatcher *dispatcher)
{
if (this->servant_dispatcher_)
delete this->servant_dispatcher_;
this->servant_dispatcher_ = dispatcher;
}
TAO_POA_Current_Impl::TAO_POA_Current_Impl (void)
: poa_ (0),
object_id_ (),
object_key_ (0),
servant_ (0),
priority_ (TAO_INVALID_PRIORITY),
previous_current_impl_ (0),
setup_done_ (0)
{
}
void
TAO_POA_Current_Impl::setup (TAO_POA *p,
const TAO::ObjectKey &key)
{
// Remember information about this upcall.
this->poa_ = p;
this->object_key_ = &key;
// Set the current context and remember the old one.
this->tss_resources_ = TAO_TSS_RESOURCES::instance ();
this->previous_current_impl_ =
ACE_static_cast (TAO_POA_Current_Impl *,
this->tss_resources_->poa_current_impl_);
this->tss_resources_->poa_current_impl_ = this;
// Setup is complete.
this->setup_done_ = 1;
}
TAO_POA_Current_Impl *
TAO_POA_Current_Impl::previous (void) const
{
return this->previous_current_impl_;
}
void
TAO_POA_Current_Impl::teardown (void)
{
if (this->setup_done_)
{
// Reset the old context.
this->tss_resources_->poa_current_impl_ = this->previous_current_impl_;
}
}
PortableServer::POA_ptr
TAO_POA_Current_Impl::get_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException,
PortableServer::Current::NoContext))
{
return PortableServer::POA::_duplicate (this->poa_);
}
PortableServer::ObjectId *
TAO_POA_Current_Impl::get_object_id (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException,
PortableServer::Current::NoContext))
{
PortableServer::ObjectId *objid = 0;
// Create a new one and pass it back
ACE_NEW_RETURN (objid,
PortableServer::ObjectId (this->object_id_),
0);
return objid;
}
TAO_ORB_Core &
TAO_POA_Current_Impl::orb_core (void) const
{
return this->poa_->orb_core_;
}
PortableServer::POA_ptr
TAO_POA_Current::get_POA (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
PortableServer::Current::NoContext))
{
TAO_POA_Current_Impl *impl = this->implementation ();
if (impl == 0)
ACE_THROW_RETURN (PortableServer::Current::NoContext (),
0);
return impl->get_POA (ACE_ENV_SINGLE_ARG_PARAMETER);
}
PortableServer::ObjectId *
TAO_POA_Current::get_object_id (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
PortableServer::Current::NoContext))
{
TAO_POA_Current_Impl *impl = this->implementation ();
if (impl == 0)
ACE_THROW_RETURN (PortableServer::Current::NoContext (),
0);
return impl->get_object_id (ACE_ENV_SINGLE_ARG_PARAMETER);
}
TAO_POA_Current_Impl *
TAO_POA_Current::implementation (void)
{
return ACE_static_cast (TAO_POA_Current_Impl *,
TAO_TSS_RESOURCES::instance ()->poa_current_impl_);
}
TAO_POA_Current_Impl *
TAO_POA_Current::implementation (TAO_POA_Current_Impl *new_current)
{
TAO_TSS_Resources *tss =
TAO_TSS_RESOURCES::instance ();
TAO_POA_Current_Impl *old =
ACE_static_cast (TAO_POA_Current_Impl *,
tss->poa_current_impl_);
tss->poa_current_impl_ = new_current;
return old;
}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
// Common typedefs.
typedef TAO_Object_Adapter::poa_name key;
typedef TAO_POA *value;
typedef ACE_Pair<key, value> expanded_value;
typedef ACE_Reference_Pair<const key, value> tao_value_type;
typedef ACE_Equal_To<key> compare_keys;
typedef TAO_ObjectId_Hash hash_key;
typedef ACE_Noop_Key_Generator<key> noop_key_generator;
template class auto_ptr<TAO_Object_Adapter::Hint_Strategy>;
template class auto_ptr<TAO_Object_Adapter::transient_poa_map>;
# if defined (ACE_LACKS_AUTO_PTR) \
|| !(defined (ACE_HAS_STANDARD_CPP_LIBRARY) \
&& (ACE_HAS_STANDARD_CPP_LIBRARY != 0))
template class ACE_Auto_Basic_Ptr<TAO_Object_Adapter::Hint_Strategy>;
template class ACE_Auto_Basic_Ptr<TAO_Object_Adapter::transient_poa_map>;
# endif /* ACE_LACKS_AUTO_PTR */
template class ACE_Noop_Key_Generator<key>;
// Common
template class ACE_Reference_Pair<const key, value>;
// Map and iterator classes.
template class ACE_Map<key, value>;
template class ACE_Iterator<tao_value_type>;
template class ACE_Reverse_Iterator<tao_value_type>;
// Iterator base classes.
template class ACE_Iterator_Impl<tao_value_type>;
template class ACE_Reverse_Iterator_Impl<tao_value_type>;
// Active Map Manager related.
template class ACE_Pair<key, value>;
template class ACE_Active_Map_Manager_Adapter<key, value, TAO_Ignore_Original_Key_Adapter>;
template class ACE_Active_Map_Manager_Adapter<key, value, TAO_Preserve_Original_Key_Adapter>;
template class ACE_Active_Map_Manager_Iterator_Adapter<tao_value_type, expanded_value>;
template class ACE_Active_Map_Manager_Reverse_Iterator_Adapter<tao_value_type, expanded_value>;
template class ACE_Active_Map_Manager<expanded_value>;
template class ACE_Map_Manager<ACE_Active_Map_Manager_Key, expanded_value, ACE_Null_Mutex>;
template class ACE_Map_Iterator_Base<ACE_Active_Map_Manager_Key, expanded_value, ACE_Null_Mutex>;
template class ACE_Map_Iterator<ACE_Active_Map_Manager_Key, expanded_value, ACE_Null_Mutex>;
template class ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, expanded_value, ACE_Null_Mutex>;
template class ACE_Map_Entry<ACE_Active_Map_Manager_Key, expanded_value>;
// Hash Map Manager related.
#if (TAO_HAS_MINIMUM_POA_MAPS == 0)
template class ACE_Hash_Map_Manager_Ex_Adapter<key, value, hash_key, compare_keys, TAO_Incremental_Key_Generator>;
#endif /* TAO_HAS_MINIMUM_POA_MAPS == 0 */
template class ACE_Hash_Map_Manager_Ex_Adapter<key, value, hash_key, compare_keys, noop_key_generator>;
template class ACE_Hash_Map_Manager_Ex_Iterator_Adapter<tao_value_type, key, value, hash_key, compare_keys>;
template class ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter<tao_value_type, key, value, hash_key, compare_keys>;
template class ACE_Hash_Map_Manager_Ex<key, value, hash_key, compare_keys, ACE_Null_Mutex>;
template class ACE_Hash_Map_Iterator_Base_Ex<key, value, hash_key, compare_keys, ACE_Null_Mutex>;
template class ACE_Hash_Map_Iterator_Ex<key, value, hash_key, compare_keys, ACE_Null_Mutex>;
template class ACE_Hash_Map_Reverse_Iterator_Ex<key, value, hash_key, compare_keys, ACE_Null_Mutex>;
template class ACE_Hash_Map_Entry<key, value>;
// Already in Active_Object_Map.cpp
// template class ACE_Equal_To<key>;
#if (TAO_HAS_MINIMUM_POA_MAPS == 0)
// Map Manager related.
template class ACE_Map_Manager_Iterator_Adapter<tao_value_type, key, value>;
template class ACE_Map_Manager_Reverse_Iterator_Adapter<tao_value_type, key, value>;
template class ACE_Map_Manager_Adapter<key, value, TAO_Incremental_Key_Generator>;
template class ACE_Map_Manager_Adapter<key, value, noop_key_generator>;
template class ACE_Map_Manager<key, value, ACE_Null_Mutex>;
template class ACE_Map_Iterator_Base<key, value, ACE_Null_Mutex>;
template class ACE_Map_Iterator<key, value, ACE_Null_Mutex>;
template class ACE_Map_Reverse_Iterator<key, value, ACE_Null_Mutex>;
template class ACE_Map_Entry<key, value>;
#endif /* TAO_HAS_MINIMUM_POA_MAPS == 0 */
template class ACE_Unbounded_Set<TAO_POA_Manager *>;
template class ACE_Node<TAO_POA_Manager *>;
template class ACE_Unbounded_Set_Iterator<TAO_POA_Manager *>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
// Common typedefs.
typedef TAO_Object_Adapter::poa_name key;
typedef TAO_POA *value;
typedef ACE_Pair<key, value> expanded_value;
typedef ACE_Reference_Pair<const key, value> tao_value_type;
typedef ACE_Equal_To<key> compare_keys;
typedef TAO_ObjectId_Hash hash_key;
typedef ACE_Noop_Key_Generator<key> noop_key_generator;
#pragma instantiate auto_ptr<TAO_Object_Adapter::Hint_Strategy>
#pragma instantiate auto_ptr<TAO_Object_Adapter::transient_poa_map>
# if defined (ACE_LACKS_AUTO_PTR) \
|| !(defined (ACE_HAS_STANDARD_CPP_LIBRARY) \
&& (ACE_HAS_STANDARD_CPP_LIBRARY != 0))
# pragma instantiate ACE_Auto_Basic_Ptr<TAO_Object_Adapter::Hint_Strategy>
# pragma instantiate ACE_Auto_Basic_Ptr<TAO_Object_Adapter::transient_poa_map>
# endif /* ACE_LACKS_AUTO_PTR */
#pragma instantiate ACE_Noop_Key_Generator<key>
// Common
#pragma instantiate ACE_Reference_Pair<const key, value>
// Map and iterator classes.
#pragma instantiate ACE_Map<key, value>
#pragma instantiate ACE_Iterator<tao_value_type>
#pragma instantiate ACE_Reverse_Iterator<tao_value_type>
// Iterator base classes.
#pragma instantiate ACE_Iterator_Impl<tao_value_type>
#pragma instantiate ACE_Reverse_Iterator_Impl<tao_value_type>
// Active Map Manager related.
#pragma instantiate ACE_Pair<key, value>
#pragma instantiate ACE_Active_Map_Manager_Adapter<key, value, TAO_Ignore_Original_Key_Adapter>
#pragma instantiate ACE_Active_Map_Manager_Adapter<key, value, TAO_Preserve_Original_Key_Adapter>
#pragma instantiate ACE_Active_Map_Manager_Iterator_Adapter<tao_value_type, expanded_value>
#pragma instantiate ACE_Active_Map_Manager_Reverse_Iterator_Adapter<tao_value_type, expanded_value>
#pragma instantiate ACE_Active_Map_Manager<expanded_value>
#pragma instantiate ACE_Map_Manager<ACE_Active_Map_Manager_Key, expanded_value, ACE_Null_Mutex>
#pragma instantiate ACE_Map_Iterator_Base<ACE_Active_Map_Manager_Key, expanded_value, ACE_Null_Mutex>
#pragma instantiate ACE_Map_Iterator<ACE_Active_Map_Manager_Key, expanded_value, ACE_Null_Mutex>
#pragma instantiate ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, expanded_value, ACE_Null_Mutex>
#pragma instantiate ACE_Map_Entry<ACE_Active_Map_Manager_Key, expanded_value>
// Hash Map
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?