active_object_map.cpp

来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C++ 代码 · 共 1,161 行 · 第 1/3 页

CPP
1,161
字号
        {
          deactivated = 1;
        }
    }
  else
    {
      result = 0;
    }

  return result;
}

int
TAO_Unique_Id_Strategy::bind_using_user_id (PortableServer::Servant servant,
                                            const PortableServer::ObjectId &user_id,
                                            CORBA::Short priority,
                                            TAO_Active_Object_Map::Map_Entry *&entry)
{
  int result = this->active_object_map_->user_id_map_->find (user_id,
                                                             entry);
  if (result == 0)
    {
      if (servant != 0)
        {
          entry->servant_ = servant;

          result = this->active_object_map_->servant_map_->bind (entry->servant_,
                                                                 entry);
        }
    }
  else
    {
      ACE_NEW_RETURN (entry,
                      TAO_Active_Object_Map::Map_Entry,
                      -1);
      entry->user_id_ = user_id;
      entry->servant_ = servant;
      entry->priority_ = priority;

      result = this->active_object_map_->id_hint_strategy_->bind (*entry);

      if (result == 0)
        {
          result = this->active_object_map_->user_id_map_->bind (entry->user_id_,
                                                                 entry);
          if (result == 0)
            {
              if (servant != 0)
                result = this->active_object_map_->servant_map_->bind (entry->servant_,
                                                                       entry);
              if (result != 0)
                {
                  this->active_object_map_->user_id_map_->unbind (entry->user_id_);
                  this->active_object_map_->id_hint_strategy_->unbind (*entry);
                  delete entry;
                }
            }
          else
            {
              this->active_object_map_->id_hint_strategy_->unbind (*entry);
              delete entry;
            }
        }
      else
        delete entry;
    }

  return result;
}

int
TAO_Unique_Id_Strategy::unbind_using_user_id (const PortableServer::ObjectId &user_id)
{
  TAO_Active_Object_Map::Map_Entry *entry = 0;
  int result = this->active_object_map_->user_id_map_->unbind (user_id,
                                                               entry);
  if (result == 0)
    {
      if (entry->servant_ != 0)
        result = this->active_object_map_->servant_map_->unbind (entry->servant_);

      if (result == 0)
        result =
          this->active_object_map_->id_hint_strategy_->unbind (*entry);

      if (result == 0)
        delete entry;
    }
  return result;
}

int
TAO_Unique_Id_Strategy::find_user_id_using_servant (PortableServer::Servant servant,
                                                    PortableServer::ObjectId_out user_id)
{
  TAO_Active_Object_Map::Map_Entry *entry = 0;
  int result = this->active_object_map_->servant_map_->find (servant,
                                                             entry);
  if (result == 0)
    {
      if (entry->deactivated_)
        result = -1;
      else
        ACE_NEW_RETURN (user_id,
                        PortableServer::ObjectId (entry->user_id_),
                        -1);
    }

  return result;
}

int
TAO_Unique_Id_Strategy::find_system_id_using_servant (PortableServer::Servant servant,
                                                      PortableServer::ObjectId_out system_id,
                                                      CORBA::Short &priority)
{
  TAO_Active_Object_Map::Map_Entry *entry = 0;
  int result = this->active_object_map_->servant_map_->find (servant,
                                                             entry);
  if (result == 0)
    {
      if (entry->deactivated_)
        result = -1;
      else
        {
          result = this->active_object_map_->id_hint_strategy_->system_id (system_id,
                                                                           *entry);
          if (result == 0)
            priority = entry->priority_;
        }
    }

  return result;
}

CORBA::Boolean
TAO_Unique_Id_Strategy::remaining_activations (PortableServer::Servant servant)
{
  ACE_UNUSED_ARG (servant);

  // Since servant are always unique here, return false.
  return 0;
}

////////////////////////////////////////////////////////////////////////////////

int
TAO_Multiple_Id_Strategy::is_servant_in_map (PortableServer::Servant,
                                             int &)
{
  return -1;
}

int
TAO_Multiple_Id_Strategy::bind_using_user_id (PortableServer::Servant servant,
                                              const PortableServer::ObjectId &user_id,
                                              CORBA::Short priority,
                                              TAO_Active_Object_Map::Map_Entry *&entry)
{
  int result = this->active_object_map_->user_id_map_->find (user_id,
                                                             entry);
  if (result == 0)
    {
      if (servant != 0)
        entry->servant_ = servant;
    }
  else
    {
      ACE_NEW_RETURN (entry,
                      TAO_Active_Object_Map::Map_Entry,
                      -1);
      entry->user_id_ = user_id;
      entry->servant_ = servant;
      entry->priority_ = priority;

      result =
        this->active_object_map_->id_hint_strategy_->bind (*entry);

      if (result == 0)
        {
          result = this->active_object_map_->user_id_map_->bind (entry->user_id_,
                                                                 entry);
          if (result != 0)
            {
              this->active_object_map_->id_hint_strategy_->unbind (*entry);
              delete entry;
            }
        }
      else
        delete entry;
    }

  return result;
}

int
TAO_Multiple_Id_Strategy::unbind_using_user_id (const PortableServer::ObjectId &user_id)
{
  TAO_Active_Object_Map::Map_Entry *entry = 0;
  int result = this->active_object_map_->user_id_map_->unbind (user_id,
                                                               entry);
  if (result == 0)
    {
      result = this->active_object_map_->id_hint_strategy_->unbind (*entry);

      if (result == 0)
        delete entry;
    }

  return result;
}

int
TAO_Multiple_Id_Strategy::find_user_id_using_servant (PortableServer::Servant servant,
                                                      PortableServer::ObjectId_out user_id)
{
  ACE_UNUSED_ARG (servant);
  ACE_UNUSED_ARG (user_id);

  return -1;
}

int
TAO_Multiple_Id_Strategy::find_system_id_using_servant (PortableServer::Servant,
                                                        PortableServer::ObjectId_out,
                                                        CORBA::Short &)
{
  return -1;
}

CORBA::Boolean
TAO_Multiple_Id_Strategy::remaining_activations (PortableServer::Servant servant)
{
  TAO_Active_Object_Map::user_id_map::iterator end
    = this->active_object_map_->user_id_map_->end ();

  for (TAO_Active_Object_Map::user_id_map::iterator iter
         = this->active_object_map_->user_id_map_->begin ();
       iter != end;
       ++iter)
    {
      TAO_Active_Object_Map::user_id_map::value_type map_pair = *iter;
      TAO_Active_Object_Map::Map_Entry *entry = map_pair.second ();

      if (entry->servant_ == servant)
        return 1;
    }

  return 0;
}

TAO_Lifespan_Strategy::~TAO_Lifespan_Strategy (void)
{
}

void
TAO_Lifespan_Strategy::set_active_object_map (TAO_Active_Object_Map *active_object_map)
{
  this->active_object_map_ = active_object_map;
}

int
TAO_Transient_Strategy::find_servant_using_system_id_and_user_id (const PortableServer::ObjectId &system_id,
                                                                  const PortableServer::ObjectId &user_id,
                                                                  PortableServer::Servant &servant,
                                                                  TAO_Active_Object_Map::Map_Entry *&entry)
{
  int result = this->active_object_map_->id_hint_strategy_->find (system_id,
                                                                  entry);
  if (result == 0)
    {
      if (entry->deactivated_)
        result = -1;
      else if (entry->servant_ == 0)
        result = -1;
      else
        servant = entry->servant_;
    }
  else
    {
      result = this->active_object_map_->user_id_map_->find (user_id,
                                                             entry);
      if (result == 0)
        {
          if (entry->deactivated_)
            result = -1;
          else if (entry->servant_ == 0)
            result = -1;
          else
            servant = entry->servant_;
        }
    }

  if (result == -1)
    entry = 0;

  return result;
}

////////////////////////////////////////////////////////////////////////////////

int
TAO_Persistent_Strategy::find_servant_using_system_id_and_user_id (const PortableServer::ObjectId &system_id,
                                                                   const PortableServer::ObjectId &user_id,
                                                                   PortableServer::Servant &servant,
                                                                   TAO_Active_Object_Map::Map_Entry *&entry)
{
  int result = this->active_object_map_->id_hint_strategy_->find (system_id,
                                                                  entry);
  if (result == 0 &&
      user_id == entry->user_id_)
    {
      if (entry->deactivated_)
        result = -1;
      else if (entry->servant_ == 0)
        result = -1;
      else
        servant = entry->servant_;
    }
  else
    {
      result = this->active_object_map_->user_id_map_->find (user_id,
                                                             entry);
      if (result == 0)
        {
          if (entry->deactivated_)
            result = -1;
          else if (entry->servant_ == 0)
            result = -1;
          else
            servant = entry->servant_;
        }
    }

  if (result == -1)
    entry = 0;

  return result;
}

TAO_Id_Assignment_Strategy::~TAO_Id_Assignment_Strategy (void)
{
}

void
TAO_Id_Assignment_Strategy::set_active_object_map (TAO_Active_Object_Map *active_object_map)
{
  this->active_object_map_ = active_object_map;
}

int
TAO_User_Id_Strategy::bind_using_system_id (PortableServer::Servant,
                                            CORBA::Short,
                                            TAO_Active_Object_Map::Map_Entry *&)
{
  return -1;
}

int
TAO_System_Id_With_Unique_Id_Strategy::bind_using_system_id (PortableServer::Servant servant,
                                                             CORBA::Short priority,
                                                             TAO_Active_Object_Map::Map_Entry *&entry)
{
  ACE_NEW_RETURN (entry,
                  TAO_Active_Object_Map::Map_Entry,
                  -1);

  int result = this->active_object_map_->user_id_map_->bind_create_key (entry,
                                                                        entry->user_id_);
  if (result == 0)
    {
      entry->servant_ = servant;
      entry->priority_ = priority;

      result = this->active_object_map_->id_hint_strategy_->bind (*entry);

      if (result == 0)
        {
          if (servant != 0)
            result = this->active_object_map_->servant_map_->bind (entry->servant_,
                                                                   entry);

          if (result != 0)
            {
              this->active_object_map_->user_id_map_->unbind (entry->user_id_);
              this->active_object_map_->id_hint_strategy_->unbind (*entry);
              delete entry;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?