*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)
*Fix a possible crash in Spell::DoAllEffectOnTarget --HG-- branch : trunk
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
//=============================================================================
|
||||
/**
|
||||
* @file Connector.h
|
||||
@@ -9,24 +8,17 @@
|
||||
* @author Douglas C. Schmidt <[email protected]>
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
#ifndef ACE_CONNECTOR_H
|
||||
#define ACE_CONNECTOR_H
|
||||
|
||||
#include /**/ "ace/pre.h"
|
||||
|
||||
#include "ace/Service_Object.h"
|
||||
|
||||
#if !defined (ACE_LACKS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif /* ACE_LACKS_PRAGMA_ONCE */
|
||||
|
||||
#include "ace/Strategies_T.h"
|
||||
#include "ace/Synch_Options.h"
|
||||
#include "ace/Unbounded_Set.h"
|
||||
|
||||
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
|
||||
|
||||
/**
|
||||
* @class ACE_Connector_Base
|
||||
*
|
||||
@@ -40,18 +32,14 @@ template <class SVC_HANDLER>
|
||||
class ACE_Connector_Base
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~ACE_Connector_Base (void) {}
|
||||
|
||||
/// Initialize the Svc_Handler.
|
||||
virtual void initialize_svc_handler (ACE_HANDLE handle,
|
||||
SVC_HANDLER *svc_handler) = 0;
|
||||
|
||||
/// Return the handle set representing the non-blocking connects in
|
||||
/// progress.
|
||||
virtual ACE_Unbounded_Set<ACE_HANDLE> &non_blocking_handles (void) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class ACE_NonBlocking_Connect_Handler
|
||||
*
|
||||
@@ -61,12 +49,10 @@ template <class SVC_HANDLER>
|
||||
class ACE_NonBlocking_Connect_Handler : public ACE_Event_Handler
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor.
|
||||
ACE_NonBlocking_Connect_Handler (ACE_Connector_Base<SVC_HANDLER> &connector,
|
||||
SVC_HANDLER *,
|
||||
long timer_id);
|
||||
|
||||
/// Close up and return underlying SVC_HANDLER through @c sh.
|
||||
/**
|
||||
* If the return value is true the close was performed succesfully,
|
||||
@@ -80,57 +66,40 @@ public:
|
||||
* object.
|
||||
*/
|
||||
bool close (SVC_HANDLER *&sh);
|
||||
|
||||
/// Get SVC_HANDLER.
|
||||
SVC_HANDLER *svc_handler (void);
|
||||
|
||||
/// Get handle.
|
||||
ACE_HANDLE handle (void);
|
||||
|
||||
/// Set handle.
|
||||
void handle (ACE_HANDLE);
|
||||
|
||||
/// Get timer id.
|
||||
long timer_id (void);
|
||||
|
||||
/// Set timer id.
|
||||
void timer_id (long timer_id);
|
||||
|
||||
/// Called by ACE_Reactor when asynchronous connections fail.
|
||||
virtual int handle_input (ACE_HANDLE);
|
||||
|
||||
/// Called by ACE_Reactor when asynchronous connections succeed.
|
||||
virtual int handle_output (ACE_HANDLE);
|
||||
|
||||
/// Called by ACE_Reactor when asynchronous connections suceeds (on
|
||||
/// some platforms only).
|
||||
virtual int handle_exception (ACE_HANDLE fd);
|
||||
|
||||
/// This method is called if a connection times out before
|
||||
/// completing.
|
||||
virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg);
|
||||
|
||||
/// Should Reactor resume us if we have been suspended before the upcall?
|
||||
virtual int resume_handler (void);
|
||||
|
||||
/// Dump the state of an object.
|
||||
void dump (void) const;
|
||||
|
||||
/// Declare the dynamic allocation hooks.
|
||||
ACE_ALLOC_HOOK_DECLARE;
|
||||
|
||||
private:
|
||||
|
||||
/// Connector base.
|
||||
ACE_Connector_Base<SVC_HANDLER> &connector_;
|
||||
|
||||
/// Associated SVC_HANDLER.
|
||||
SVC_HANDLER *svc_handler_;
|
||||
|
||||
/// Associated timer id.
|
||||
long timer_id_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class ACE_Connector
|
||||
*
|
||||
@@ -150,7 +119,6 @@ template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1>
|
||||
class ACE_Connector : public ACE_Connector_Base<SVC_HANDLER>, public ACE_Service_Object
|
||||
{
|
||||
public:
|
||||
|
||||
// Useful STL-style traits.
|
||||
typedef typename SVC_HANDLER::addr_type addr_type;
|
||||
typedef ACE_PEER_CONNECTOR connector_type;
|
||||
@@ -158,7 +126,6 @@ public:
|
||||
typedef typename SVC_HANDLER::stream_type stream_type;
|
||||
typedef typename ACE_PEER_CONNECTOR::PEER_ADDR peer_addr_type;
|
||||
typedef ACE_PEER_CONNECTOR_ADDR ACE_PEER_ADDR_TYPEDEF;
|
||||
|
||||
/**
|
||||
* Initialize a connector. @a flags indicates how SVC_HANDLER's
|
||||
* should be initialized prior to being activated. Right now, the
|
||||
@@ -167,7 +134,6 @@ public:
|
||||
*/
|
||||
ACE_Connector (ACE_Reactor *r = ACE_Reactor::instance (),
|
||||
int flags = 0);
|
||||
|
||||
/**
|
||||
* Initialize a connector. @a flags indicates how SVC_HANDLER's
|
||||
* should be initialized prior to being activated. Right now, the
|
||||
@@ -176,12 +142,9 @@ public:
|
||||
*/
|
||||
virtual int open (ACE_Reactor *r = ACE_Reactor::instance (),
|
||||
int flags = 0);
|
||||
|
||||
/// Shutdown a connector and release resources.
|
||||
virtual ~ACE_Connector (void);
|
||||
|
||||
// = Connection establishment methods.
|
||||
|
||||
/**
|
||||
* Initiate connection of @a svc_handler to peer at @a remote_addr
|
||||
* using @a synch_options. If the caller wants to designate the
|
||||
@@ -201,7 +164,6 @@ public:
|
||||
int reuse_addr = 0,
|
||||
int flags = O_RDWR,
|
||||
int perms = 0);
|
||||
|
||||
/**
|
||||
* This is a variation on the previous <connect> method. On cached
|
||||
* connectors the @a svc_handler_hint variable can be used as a hint
|
||||
@@ -221,7 +183,6 @@ public:
|
||||
int reuse_addr = 0,
|
||||
int flags = O_RDWR,
|
||||
int perms = 0);
|
||||
|
||||
/**
|
||||
* Initiate connection of @a n @a svc_handlers to peers at
|
||||
* @a remote_addrs using @a synch_options. Returns -1 if failure
|
||||
@@ -236,7 +197,6 @@ public:
|
||||
ACE_TCHAR *failed_svc_handlers = 0,
|
||||
const ACE_Synch_Options &synch_options =
|
||||
ACE_Synch_Options::defaults);
|
||||
|
||||
/**
|
||||
* Cancel the @a svc_handler that was started asynchronously. Note that
|
||||
* this is the only case when the Connector does not actively close
|
||||
@@ -244,37 +204,27 @@ public:
|
||||
* decide the fate of the @a svc_handler.
|
||||
*/
|
||||
virtual int cancel (SVC_HANDLER *svc_handler);
|
||||
|
||||
/// Close down the Connector. All pending non-blocking connects are
|
||||
/// canceled and the corresponding svc_handler is closed.
|
||||
virtual int close (void);
|
||||
|
||||
/// Return the underlying PEER_CONNECTOR object.
|
||||
virtual ACE_PEER_CONNECTOR &connector (void) const;
|
||||
|
||||
/// Initialize Svc_Handler.
|
||||
virtual void initialize_svc_handler (ACE_HANDLE handle,
|
||||
SVC_HANDLER *svc_handler);
|
||||
|
||||
/// Set Reactor.
|
||||
virtual void reactor (ACE_Reactor *reactor);
|
||||
|
||||
/// Get Reactor.
|
||||
virtual ACE_Reactor *reactor (void) const;
|
||||
|
||||
/// Dump the state of an object.
|
||||
void dump (void) const;
|
||||
|
||||
/// Declare the dynamic allocation hooks.
|
||||
ACE_ALLOC_HOOK_DECLARE;
|
||||
|
||||
protected:
|
||||
// = Helpful typedefs.
|
||||
typedef ACE_NonBlocking_Connect_Handler<SVC_HANDLER> NBCH;
|
||||
|
||||
// = The following two methods define the Connector's strategies for
|
||||
// creating, connecting, and activating SVC_HANDLER's, respectively.
|
||||
|
||||
/**
|
||||
* Bridge method for creating a SVC_HANDLER. The default is to
|
||||
* create a new SVC_HANDLER only if @a sh == 0, else @a sh is
|
||||
@@ -285,7 +235,6 @@ protected:
|
||||
* else 0.
|
||||
*/
|
||||
virtual int make_svc_handler (SVC_HANDLER *&sh);
|
||||
|
||||
/**
|
||||
* Bridge method for connecting the @a svc_handler to the
|
||||
* @a remote_addr. The default behavior delegates to the
|
||||
@@ -306,7 +255,6 @@ protected:
|
||||
int reuse_addr,
|
||||
int flags,
|
||||
int perms);
|
||||
|
||||
/**
|
||||
* Bridge method for activating a @a svc_handler with the appropriate
|
||||
* concurrency strategy. The default behavior of this method is to
|
||||
@@ -318,11 +266,9 @@ protected:
|
||||
* multi-processing).
|
||||
*/
|
||||
virtual int activate_svc_handler (SVC_HANDLER *svc_handler);
|
||||
|
||||
/// Creates and registers ACE_NonBlocking_Connect_Handler.
|
||||
int nonblocking_connect (SVC_HANDLER *,
|
||||
const ACE_Synch_Options &);
|
||||
|
||||
/// Implementation of the connect methods.
|
||||
virtual int connect_i (SVC_HANDLER *&svc_handler,
|
||||
SVC_HANDLER **sh_copy,
|
||||
@@ -332,35 +278,27 @@ protected:
|
||||
int reuse_addr,
|
||||
int flags,
|
||||
int perms);
|
||||
|
||||
/// Return the handle set representing the non-blocking connects in
|
||||
/// progress.
|
||||
ACE_Unbounded_Set<ACE_HANDLE> &non_blocking_handles (void);
|
||||
|
||||
// = Dynamic linking hooks.
|
||||
/// Default version does no work and returns -1. Must be overloaded
|
||||
/// by application developer to do anything meaningful.
|
||||
virtual int init (int argc, ACE_TCHAR *argv[]);
|
||||
|
||||
/// Calls handle_close() to shutdown the Connector gracefully.
|
||||
virtual int fini (void);
|
||||
|
||||
/// Default version returns address info in @a buf.
|
||||
virtual int info (ACE_TCHAR **strp, size_t length) const;
|
||||
|
||||
// = Service management hooks.
|
||||
/// Default version does no work and returns -1. Must be overloaded
|
||||
/// by application developer to do anything meaningful.
|
||||
virtual int suspend (void);
|
||||
|
||||
/// Default version does no work and returns -1. Must be overloaded
|
||||
/// by application developer to do anything meaningful.
|
||||
virtual int resume (void);
|
||||
|
||||
private:
|
||||
/// This is the peer connector factory.
|
||||
ACE_PEER_CONNECTOR connector_;
|
||||
|
||||
/**
|
||||
* Flags that indicate how SVC_HANDLER's should be initialized
|
||||
* prior to being activated. Right now, the only flag that is
|
||||
@@ -368,15 +306,11 @@ private:
|
||||
* the SVC_HANDLER when it is opened.
|
||||
*/
|
||||
int flags_;
|
||||
|
||||
/// Pointer to the Reactor.
|
||||
ACE_Reactor *reactor_;
|
||||
|
||||
/// Handle set representing the non-blocking connects in progress.
|
||||
ACE_Unbounded_Set<ACE_HANDLE> non_blocking_handles_;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @class ACE_Strategy_Connector
|
||||
*
|
||||
@@ -396,7 +330,6 @@ class ACE_Strategy_Connector
|
||||
: public ACE_Connector <SVC_HANDLER, ACE_PEER_CONNECTOR_2>
|
||||
{
|
||||
public:
|
||||
|
||||
// Useful STL-style traits.
|
||||
typedef ACE_Creation_Strategy<SVC_HANDLER>
|
||||
creation_strategy_type;
|
||||
@@ -406,7 +339,6 @@ public:
|
||||
concurrency_strategy_type;
|
||||
typedef ACE_Connector <SVC_HANDLER, ACE_PEER_CONNECTOR_2>
|
||||
base_type;
|
||||
|
||||
// = Define some useful (old style) traits.
|
||||
typedef ACE_Creation_Strategy<SVC_HANDLER>
|
||||
CREATION_STRATEGY;
|
||||
@@ -416,7 +348,6 @@ public:
|
||||
CONCURRENCY_STRATEGY;
|
||||
typedef ACE_Connector <SVC_HANDLER, ACE_PEER_CONNECTOR_2>
|
||||
SUPER;
|
||||
|
||||
/**
|
||||
* Initialize a connector. @a flags indicates how <SVC_HANDLER>'s
|
||||
* should be initialized prior to being activated. Right now, the
|
||||
@@ -428,7 +359,6 @@ public:
|
||||
ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2> * = 0,
|
||||
ACE_Concurrency_Strategy<SVC_HANDLER> * = 0,
|
||||
int flags = 0);
|
||||
|
||||
/**
|
||||
* Initialize a connector. @a flags indicates how SVC_HANDLER's
|
||||
* should be initialized prior to being activated. Right now, the
|
||||
@@ -438,7 +368,6 @@ public:
|
||||
*/
|
||||
virtual int open (ACE_Reactor *r,
|
||||
int flags);
|
||||
|
||||
/**
|
||||
* Initialize a connector. @a flags indicates how SVC_HANDLER's
|
||||
* should be initialized prior to being activated. Right now, the
|
||||
@@ -450,23 +379,18 @@ public:
|
||||
ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2> * = 0,
|
||||
ACE_Concurrency_Strategy<SVC_HANDLER> * = 0,
|
||||
int flags = 0);
|
||||
|
||||
/// Shutdown a connector and release resources.
|
||||
virtual ~ACE_Strategy_Connector (void);
|
||||
|
||||
/// Close down the Connector
|
||||
virtual int close (void);
|
||||
|
||||
// = Strategies accessors
|
||||
virtual ACE_Creation_Strategy<SVC_HANDLER> *creation_strategy (void) const;
|
||||
virtual ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2> *connect_strategy (void) const;
|
||||
virtual ACE_Concurrency_Strategy<SVC_HANDLER> *concurrency_strategy (void) const;
|
||||
|
||||
protected:
|
||||
// = The following three methods define the <Connector>'s strategies
|
||||
// for creating, connecting, and activating SVC_HANDLER's,
|
||||
// respectively.
|
||||
|
||||
/**
|
||||
* Bridge method for creating a SVC_HANDLER. The strategy for
|
||||
* creating a SVC_HANDLER are configured into the Connector via
|
||||
@@ -479,7 +403,6 @@ protected:
|
||||
* else 0.
|
||||
*/
|
||||
virtual int make_svc_handler (SVC_HANDLER *&sh);
|
||||
|
||||
/**
|
||||
* Bridge method for connecting the new connection into the
|
||||
* SVC_HANDLER. The default behavior delegates to the
|
||||
@@ -492,7 +415,6 @@ protected:
|
||||
int reuse_addr,
|
||||
int flags,
|
||||
int perms);
|
||||
|
||||
/**
|
||||
* Bridge method for connecting the new connection into the
|
||||
* SVC_HANDLER. The default behavior delegates to the
|
||||
@@ -511,7 +433,6 @@ protected:
|
||||
int reuse_addr,
|
||||
int flags,
|
||||
int perms);
|
||||
|
||||
/**
|
||||
* Bridge method for activating a SVC_HANDLER with the appropriate
|
||||
* concurrency strategy. The default behavior of this method is to
|
||||
@@ -523,42 +444,30 @@ protected:
|
||||
* multi-processing).
|
||||
*/
|
||||
virtual int activate_svc_handler (SVC_HANDLER *svc_handler);
|
||||
|
||||
// = Strategy objects.
|
||||
|
||||
/// Creation strategy for an Connector.
|
||||
CREATION_STRATEGY *creation_strategy_;
|
||||
|
||||
/// true if Connector created the creation strategy and thus should
|
||||
/// delete it, else false.
|
||||
bool delete_creation_strategy_;
|
||||
|
||||
/// Connect strategy for a Connector.
|
||||
CONNECT_STRATEGY *connect_strategy_;
|
||||
|
||||
/// true if Connector created the connect strategy and thus should
|
||||
/// delete it, else false.
|
||||
bool delete_connect_strategy_;
|
||||
|
||||
/// Concurrency strategy for an <Connector>.
|
||||
CONCURRENCY_STRATEGY *concurrency_strategy_;
|
||||
|
||||
/// true if Connector created the concurrency strategy and thus should
|
||||
/// delete it, else false.
|
||||
bool delete_concurrency_strategy_;
|
||||
};
|
||||
|
||||
ACE_END_VERSIONED_NAMESPACE_DECL
|
||||
|
||||
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
|
||||
#include "ace/Connector.cpp"
|
||||
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
|
||||
|
||||
#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
|
||||
#pragma implementation ("Connector.cpp")
|
||||
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
|
||||
|
||||
#include /**/ "ace/post.h"
|
||||
|
||||
#endif /* ACE_CONNECTOR_H */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user