本文整理汇总了C++中ACE_Auto_Ptr类的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Auto_Ptr类的具体用法?C++ ACE_Auto_Ptr怎么用?C++ ACE_Auto_Ptr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ACE_Auto_Ptr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DBG_ENTRY
int OpenDDS::DCPS::ThreadPerConnectionSendTask::add_request(SendStrategyOpType op,
TransportQueueElement* element)
{
DBG_ENTRY("ThreadPerConnectionSendTask","add");
ACE_Auto_Ptr<SendRequest> req (new SendRequest);
req->op_ = op;
req->element_ = element;
int result = -1;
{ // guard scope
GuardType guard(this->lock_);
if (this->shutdown_initiated_)
return -1;
result = this->queue_.put (req.get());
if (result == 0)
{
this->work_available_.signal();
req.release ();
}
else
ACE_ERROR((LM_ERROR, "(%P|%t)ERROR: ThreadPerConnectionSendTask::add %p\n", "put"));
}
return result;
}
示例2: next_group_id_
TAO::PG_Group_List_Store::PG_Group_List_Store (
Storable_Factory & storable_factory)
: next_group_id_ (0)
, storable_factory_ (storable_factory)
, loaded_from_stream_ (false)
, last_changed_ (0)
, stale_ (false)
{
// Create a temporary stream simply to check if a readable
// version already exists.
bool stream_exists = false;
{
ACE_Auto_Ptr<TAO::Storable_Base> stream (
this->create_stream ("r"));
if (stream->exists ())
stream_exists = true;
}
if (stream_exists)
{
File_Guard fg(*this, SFG::CREATE_WITH_FILE);
}
else
{
File_Guard fg(*this, SFG::CREATE_WITHOUT_FILE);
this->write (fg.peer ());
}
}
示例3: safe
::Test::arr_bds_str_slice *
A_i::arr_method_s (::Test::A::FailOn where,
const ::Test::arr_bds_str,
::Test::arr_bds_str_out arg2,
::Test::arr_bds_str arg3)
{
arg2 = ::Test::arr_bds_str_alloc ();
::Test::arr_bds_str_slice *res =
::Test::arr_bds_str_alloc ();
ACE_Auto_Ptr< ::Test::arr_bds_str_slice > safe (res);
switch (where)
{
case ::Test::A::ARG1:
// must be never reached.
break;
case ::Test::A::ARG2:
{
::Test::arr_bds_str_slice *& arg2_slice = arg2;
arg2_slice[0] = CORBA::string_dup (::Test::FailStr);
}
break;
case ::Test::A::ARG3:
arg3[0] = CORBA::string_dup (::Test::FailStr);
break;
case ::Test::A::RETN:
res[0] = CORBA::string_dup (::Test::FailStr);
break;
}
safe.release ();
return res;
}
示例4: storable_factory_
Savable::Savable (TAO::Storable_Factory & storable_factory)
: storable_factory_(storable_factory)
, loaded_from_stream_ (false)
{
for (int index = 0; index < 2; ++index)
{
this->i_[index] = 0;
this->ui_[index] = 0;
this->bytes_size_[index] = 0;
this->bytes_[index] = new char [this->bytes_size_max];
for (int i = 0; i < this->bytes_size_max; ++i)
{
this->bytes_[index][i] = ACE_CHAR_MAX;
}
}
ACE_Auto_Ptr<TAO::Storable_Base>
stream (storable_factory_.create_stream("test.dat", "r"));
if (stream->exists ())
{
Savable_File_Guard fg(*this, SFG::CREATE_WITH_FILE);
}
else
{
Savable_File_Guard fg(*this, SFG::CREATE_WITHOUT_FILE);
this->write (fg.peer ());
}
}
示例5: stream
bool
TAO::PG_Group_List_Store::list_obsolete ()
{
// TODO: Upate if obsolete flag is set based on CORBA call.
ACE_Auto_Ptr<TAO::Storable_Base> stream (this->create_stream ("r"));
if (!stream->exists ())
throw CORBA::INTERNAL ();
if (stream->open () != 0)
throw CORBA::INTERNAL ();
return this->is_obsolete (stream->last_changed ());
}
示例6: stream
TAO::PG_Object_Group_Storable::~PG_Object_Group_Storable (void)
{
if (destroyed_)
{
ACE_Auto_Ptr<TAO::Storable_Base> stream (
this->create_stream ("r"));
if (stream->exists ())
{
stream->remove ();
}
}
}
示例7: sig
int
HTTP_Server::init (int argc, ACE_TCHAR *argv[])
// Document this function
{
// Ignore signals generated when a connection is broken unexpectedly.
ACE_Sig_Action sig ((ACE_SignalHandler) SIG_IGN, SIGPIPE);
ACE_UNUSED_ARG (sig);
// Parse arguments which sets the initial state.
this->parse_args (argc, argv);
//If the IO strategy is synchronous (SYNCH case), then choose a handler
//factory based on the desired caching scheme
HTTP_Handler_Factory *f = 0;
if (this->strategy_ != (JAWS::JAWS_POOL | JAWS::JAWS_ASYNCH))
{
if (this->caching_)
{
ACE_NEW_RETURN (f, Synch_HTTP_Handler_Factory (), -1);
}
else
{
ACE_NEW_RETURN (f, No_Cache_Synch_HTTP_Handler_Factory (), -1);
}
}
//NOTE: At this point f better not be a NULL pointer,
//so please do not change the ACE_NEW_RETURN macros unless
//you know what you are doing
ACE_Auto_Ptr<HTTP_Handler_Factory> factory (f);
// Choose what concurrency strategy to run.
switch (this->strategy_)
{
case (JAWS::JAWS_POOL | JAWS::JAWS_ASYNCH) :
return this->asynch_thread_pool ();
case (JAWS::JAWS_PER_REQUEST | JAWS::JAWS_SYNCH) :
return this->thread_per_request (*factory.get ());
case (JAWS::JAWS_POOL | JAWS::JAWS_SYNCH) :
default:
return this->synch_thread_pool (*factory.get ());
}
ACE_NOTREACHED (return 0);
}
示例8: PG_Object_Group
TAO::PG_Object_Group_Storable::PG_Object_Group_Storable (
CORBA::ORB_ptr orb,
PortableGroup::FactoryRegistry_ptr factory_registry,
TAO::PG_Object_Group_Manipulator & manipulator,
CORBA::Object_ptr empty_group,
const PortableGroup::TagGroupTaggedComponent & tagged_component,
const char * type_id,
const PortableGroup::Criteria & the_criteria,
const TAO::PG_Property_Set_var & type_properties,
TAO::Storable_Factory & storable_factory)
: PG_Object_Group(orb,
factory_registry,
manipulator,
empty_group,
tagged_component,
type_id,
the_criteria,
type_properties)
, group_previously_stored_(false)
, group_id_previously_stored_(0)
, storable_factory_ (storable_factory)
, last_changed_ (0)
, loaded_from_stream_ (false)
, destroyed_ (false)
, write_occurred_ (false)
{
// Create a temporary stream simply to check if a readable
// version already exists.
bool stream_exists = false;
{
ACE_Auto_Ptr<TAO::Storable_Base> stream (
this->create_stream ("r"));
if (stream->exists ())
stream_exists = true;
}
if (stream_exists)
{
Object_Group_File_Guard fg (*this, SFG::CREATE_WITH_FILE);
}
else
{
Object_Group_File_Guard fg (*this, SFG::CREATE_WITHOUT_FILE);
this->write (fg.peer ());
}
}
示例9: DANCE_TRACE
bool
STD_PC_Intf::prepare_PC (const char *file)
{
DANCE_TRACE("STD_PC_Intf::prepare_PC");
ACE_Auto_Ptr<XML_Helper> helper (new XML_Helper);
if (!helper->is_initialized ())
return false;
// parse the .pcd (PackageConfigurationDescription) file
xercesc::DOMDocument *dom =
helper->create_dom (file);
if (!dom)
return false;
PackageConfiguration pc =
packageConfiguration (dom);
Deployment::PackageConfiguration idl_pc;
STD_PCD_Handler pcd_handler (helper.get ());
pcd_handler.package_config (pc,
idl_pc);
Deployment::PackageConfiguration *p_idl_pc =
new Deployment::PackageConfiguration (idl_pc);
// let ACE_Auto_Ptr take over
this->idl_pc_.reset (p_idl_pc);
if (this->idl_pc_.get ())
return true;
return false;
}
示例10: while
void
TAO_Leader_Follower::resume_events ()
{
// not need to obtain the lock, only called when holding the lock
while (!this->deferred_event_set_.is_empty ())
{
ACE_Auto_Ptr<Deferred_Event> event (this->deferred_event_set_.pop_front ());
// Send a notification to the reactor to cause the awakening of a new
// follower, if there is one already available.
ACE_Reactor *reactor = this->orb_core_->reactor ();
int const retval = reactor->notify (event->handler (), ACE_Event_Handler::READ_MASK);
if (TAO_debug_level > 2)
{
// @@todo: need to think about what is the action that
// we can take when we get here with an error?!
TAOLIB_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO (%P|%t) - TAO_Leader_Follower::resume_events, ")
ACE_TEXT ("an event handler[%d] has been resumed, ")
ACE_TEXT ("notified the reactor, retval=%d.\n"),
event->handler ()->get_handle (), retval));
}
}
}
示例11: ACE_TRACE
int
ACE_Service_Gestalt::initialize (const ACE_Service_Type_Factory *stf,
const ACE_TCHAR *parameters)
{
ACE_TRACE ("ACE_Service_Gestalt::initialize");
#ifndef ACE_NLOGGING
if (ACE::debug ())
ACELIB_DEBUG ((LM_DEBUG,
ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@, name=%s")
ACE_TEXT (" - looking up in the repo\n"),
this->repo_,
stf->name ()));
#endif
ACE_Service_Type *srp = 0;
int const retv = this->repo_->find (stf->name (),
(const ACE_Service_Type **) &srp);
// If there is an active service already, remove it first
// before it can be re-installed.
if (retv >= 0)
{
#ifndef ACE_NLOGGING
if (ACE::debug ())
ACELIB_DEBUG ((LM_WARNING,
ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@,")
ACE_TEXT (" name=%s - removing a pre-existing namesake.\n"),
this->repo_,
stf->name ()));
#endif
this->repo_->remove (stf->name ());
}
// If there is an inactive service by that name it may have been
// either inactivated, or just a forward declaration for a service,
// that is in the process of being initialized. If it is the latter,
// then we have detected an attempt to initialize the same dynamic
// service while still processing previous attempt. This can lock up
// the process, because the ACE_DLL_Manager::open () is not
// re-entrant - it uses a Singleton lock to serialize concurent
// invocations. This use case must be handled here, because if the
// DLL_Manager was re-entrant we would have entered an infinite
// recursion here.
if (retv == -2 && srp->type () == 0)
ACELIB_ERROR_RETURN ((LM_WARNING,
ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@,")
ACE_TEXT (" name=%s - forward-declared; ")
ACE_TEXT (" recursive initialization requests are")
ACE_TEXT (" ignored.\n"),
this->repo_,
stf->name ()),
-1);
// Reserve a spot for the dynamic service by inserting an incomplete
// service declaration, i.e. one that can not produce a service
// object if asked (a forward declaration). This declaration
// ensures maintaining the proper partial ordering of the services
// with respect to their finalization. For example, dependent static
// services must be registered *after* the dynamic service that
// loads them, so that their finalization is complete *before*
// finalizing the dynamic service.
ACE_Service_Type_Dynamic_Guard dummy (*this->repo_,
stf->name ());
// make_service_type() is doing the dynamic loading and also runs
// any static initializers
ACE_Auto_Ptr<ACE_Service_Type> tmp (stf->make_service_type (this));
if (tmp.get () != 0 &&
this->initialize_i (tmp.get (), parameters) == 0)
{
// All good. Tthe ACE_Service_Type instance is now owned by the
// repository and we should make sure it is not destroyed upon
// exit from this method.
tmp.release ();
return 0;
}
return -1;
}
示例12: ACE_ASSERT
int WorldSocket::ProcessIncoming(WorldPacket* new_pct)
{
ACE_ASSERT (new_pct);
// manage memory ;)
ACE_Auto_Ptr<WorldPacket> aptr (new_pct);
const ACE_UINT16 opcode = new_pct->GetOpcode();
if (closing_)
return -1;
// Dump received packet.
if (sPacketLog->CanLogPacket())
sPacketLog->LogPacket(*new_pct, CLIENT_TO_SERVER);
try
{
switch (opcode)
{
case CMSG_PING:
return HandlePing (*new_pct);
case CMSG_AUTH_SESSION:
if (m_Session)
{
sLog->outError("WorldSocket::ProcessIncoming: Player send CMSG_AUTH_SESSION again");
return -1;
}
sScriptMgr->OnPacketReceive(this, WorldPacket(*new_pct));
return HandleAuthSession(*new_pct);
case CMSG_KEEP_ALIVE:
sLog->outStaticDebug ("CMSG_KEEP_ALIVE, size: " UI64FMTD, uint64(new_pct->size()));
sScriptMgr->OnPacketReceive(this, WorldPacket(*new_pct));
return 0;
default:
{
ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1);
if (m_Session != NULL)
{
// Our Idle timer will reset on any non PING opcodes.
// Catches people idling on the login screen and any lingering ingame connections.
m_Session->ResetTimeOutTime();
// OK, give the packet to WorldSession
aptr.release();
// WARNINIG here we call it with locks held.
// Its possible to cause deadlock if QueuePacket calls back
m_Session->QueuePacket (new_pct);
return 0;
}
else
{
sLog->outError("WorldSocket::ProcessIncoming: Client not authed opcode = %u", uint32(opcode));
return -1;
}
}
}
}
catch (ByteBufferException &)
{
sLog->outError("WorldSocket::ProcessIncoming ByteBufferException occured while parsing an instant handled packet (opcode: %u) from client %s, accountid=%i. Disconnected client.",
opcode, GetRemoteAddress().c_str(), m_Session?m_Session->GetAccountId():-1);
if (sLog->IsOutDebug())
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "Dumping error causing packet:");
new_pct->hexlike();
}
return -1;
}
ACE_NOTREACHED (return 0);
}
示例13: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
CORBA::ORB_var s_orb;
// Find the Naming Service.
CORBA::Object_var obj = orb->resolve_initial_references ("NameService");
CosNaming::NamingContextExt_var root_context =
CosNaming::NamingContextExt::_narrow (obj.in ());
obj = root_context->resolve_str ("CosEventService");
// Downcast the object reference to an EventChannel reference.
CosEventChannelAdmin::EventChannel_var ec =
CosEventChannelAdmin::EventChannel::_narrow (obj.in ());
if (CORBA::is_nil (ec.in ()))
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Could not narrow the EventChannel.\n")));
return 1;
}
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Found the EventChannel.\n")));
bool consumer = false;
bool supplier = false;
bool hang = false;
for (int i=1; i < argc; ++i)
{
if (0 == ACE_OS::strcasecmp (argv[i], ACE_TEXT ("-consumer")))
consumer = true;
else if (0 == ACE_OS::strcasecmp (argv[i], ACE_TEXT ("-supplier")))
supplier = true;
else if (0 == ACE_OS::strcasecmp (argv[i], ACE_TEXT ("-hang")))
hang = true;
}
TestEventConsumer_i servant (orb.in (), hang);
if (consumer)
{
// Register it with the RootPOA.
obj = orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var poa =
PortableServer::POA::_narrow (obj.in ());
PortableServer::ObjectId_var oid = poa->activate_object (&servant);
CORBA::Object_var consumer_obj = poa->id_to_reference (oid.in ());
CosEventComm::PushConsumer_var consumer =
CosEventComm::PushConsumer::_narrow (consumer_obj.in ());
// Get a ConsumerAdmin object from the EventChannel.
CosEventChannelAdmin::ConsumerAdmin_var consumerAdmin =
ec->for_consumers ();
// Get a ProxyPushSupplier from the ConsumerAdmin.
CosEventChannelAdmin::ProxyPushSupplier_var supplier =
consumerAdmin->obtain_push_supplier ();
// Connect to the ProxyPushSupplier, passing our PushConsumer object
// reference to it.
supplier->connect_push_consumer (consumer.in ());
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Consumer connected\n")));
// Activate the POA via its POAManager.
PortableServer::POAManager_var poa_manager = poa->the_POAManager ();
poa_manager->activate ();
servant.activate ();
}
ACE_Auto_Ptr<SupplierTask> pST;
if (supplier)
{
// The supplier will use its own ORB.
CORBA::String_var ec_str = orb->object_to_string (ec.in ());
int no_args = 0;
ACE_TCHAR **no_argv = 0;
s_orb = CORBA::ORB_init (no_args, no_argv,
"Supplier_pure_client_ORB");
CORBA::Object_var s_ec_obj = s_orb->string_to_object (ec_str.in ());
CosEventChannelAdmin::EventChannel_var s_ec =
CosEventChannelAdmin::EventChannel::_narrow (s_ec_obj.in ());
// Get a SupplierAdmin object from the EventChannel.
CosEventChannelAdmin::SupplierAdmin_var supplierAdmin =
s_ec->for_suppliers ();
// Get a ProxyPushConsumer from the SupplierAdmin.
CosEventChannelAdmin::ProxyPushConsumer_var consumer =
supplierAdmin->obtain_push_consumer ();
// Connect to the ProxyPushConsumer as a PushSupplier
// (passing a nil PushSupplier object reference to it because
// we don't care to be notified about disconnects).
consumer->connect_push_supplier
(CosEventComm::PushSupplier::_nil ());
//.........这里部分代码省略.........
示例14: ACE_ASSERT
int PoolSocket::ProcessIncoming (WorldPacket* new_pct)
{
ACE_ASSERT (new_pct);
// manage memory ;)
ACE_Auto_Ptr<WorldPacket> aptr (new_pct);
const ACE_UINT16 opcode = new_pct->GetOpcode();
if (closing_)
return -1;
// Dump received packet.
if (sPacketLog->CanLogPacket())
sPacketLog->LogPacket(*new_pct, CLIENT_TO_SERVER);
try
{
switch (opcode)
{
case CMSG_PING:
return HandlePing (*new_pct);
case LOGON_AUTH_MASTER:
if (m_Session)
{
sLog->outError ("PoolSocket::ProcessIncoming: Player send CMSG_AUTH_SESSION again");
return -1;
}
return HandleAuthSession (*new_pct);
case CMSG_KEEP_ALIVE:
sLog->outStaticDebug ("CMSG_KEEP_ALIVE, size: " UI64FMTD, uint64(new_pct->size()));
return 0;
default:
{
ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1);
if (m_Session != NULL)
{
// OK, give the packet to WorldSession
aptr.release();
// WARNINIG here we call it with locks held.
// Its possible to cause deadlock if QueuePacket calls back
m_Session->QueueServerPacket (new_pct);
return 0;
}
else
{
new_pct->Initialize(SMSG_AUTH_RESPONSE, 1);
*new_pct << uint8(AUTH_REJECT);
SendPacket(*new_pct);
sLog->outError ("PoolSocket::ProcessIncoming: Client not authed opcode = %u => rejected", uint32(opcode));
return -1;
}
}
}
}
catch (ByteBufferException &)
{
sLog->outError("PoolSocket::ProcessIncoming ByteBufferException occured while parsing an instant handled packet (opcode: %u) from client %s, accountid=%i. Disconnected client.",
opcode, GetRemoteAddress().c_str(), m_Session?m_Session->GetServerId():-1);
if (sLog->IsOutDebug())
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "Dumping error causing packet:");
new_pct->hexlike();
}
return -1;
}
ACE_NOTREACHED (return 0);
}
示例15: ACE_ASSERT
int WorldSocket::ProcessIncoming (WorldPacket* new_pct)
{
ACE_ASSERT (new_pct);
// manage memory ;)
ACE_Auto_Ptr<WorldPacket> aptr (new_pct);
const ACE_UINT16 opcode = new_pct->GetOpcode ();
if (closing_)
return -1;
// Dump received packet.
if (sWorldLog.LogWorld ())
{
sWorldLog.Log ("CLIENT:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n",
(uint32) get_handle (),
new_pct->size (),
LookupOpcodeName (new_pct->GetOpcode ()),
new_pct->GetOpcode ());
uint32 p = 0;
while (p < new_pct->size ())
{
for (uint32 j = 0; j < 16 && p < new_pct->size (); j++)
sWorldLog.Log ("%.2X ", (*new_pct)[p++]);
sWorldLog.Log ("\n");
}
sWorldLog.Log ("\n\n");
}
// like one switch ;)
if (opcode == CMSG_PING)
{
return HandlePing (*new_pct);
}
else if (opcode == CMSG_AUTH_SESSION)
{
if (m_Session)
{
sLog.outError ("WorldSocket::ProcessIncoming: Player send CMSG_AUTH_SESSION again");
return -1;
}
return HandleAuthSession (*new_pct);
}
else if (opcode == CMSG_KEEP_ALIVE)
{
DEBUG_LOG ("CMSG_KEEP_ALIVE ,size: %d", new_pct->size ());
return 0;
}
else
{
ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1);
if (m_Session != NULL)
{
// OK ,give the packet to WorldSession
aptr.release ();
// WARNINIG here we call it with locks held.
// Its possible to cause deadlock if QueuePacket calls back
m_Session->QueuePacket (new_pct);
return 0;
}
else
{
sLog.outError ("WorldSocket::ProcessIncoming: Client not authed opcode = ", opcode);
return -1;
}
}
ACE_NOTREACHED (return 0);
}