Public Types | |
typedef std::vector < JetByteTools::Core::_tstring > | Names |
typedef std::vector < IServerControl::Status > | Statuses |
enum | Status { NotStarted, AcceptingConnections, Paused, ShuttingDown, Stopped, Indeterminate } |
Public Member Functions | |
CNamedServerCollection () | |
Creates an empty collection. | |
CNamedServerCollection (const CNamedServerCollection &rhs) | |
~CNamedServerCollection () override | |
CNamedServerCollection & | operator= (const CNamedServerCollection &rhs) |
void | AddServer (const JetByteTools::Core::_tstring &name, IServerControl *pServer) |
Adds an instance of IServerControl to the collection and takes ownership of the instance; it will be deleted when the collection is destroyed. | |
void | AddServer (const JetByteTools::Core::_tstring &name, IServerControl &server) |
Adds an instance of IServerControl to the collection and does not take ownership of the instance. | |
IServerControl * | RemoveServer (const JetByteTools::Core::_tstring &name) |
Locates an instance of IServerControl by name and removes it from the collection and returns it. If the instance was owned by the collection then it is no longer owned by the collection and the caller now owns the instance. Returns 0 if an instance of the supplied name does not exist. | |
void | RemoveServers () |
Removes all instances from the collection and destroys those instances that the collection owns. | |
void | StartAcceptingConnections (const Names &serversToStart) |
void | StopAcceptingConnections (Names &serversThatWereStopped) |
void | StopTheseServersFromAcceptingConnections (const Names &serversToStop) |
IServerControl & | GetServer (const JetByteTools::Core::_tstring &name) const override |
Obtains a reference to an instance of IServerControl from the collection by name. If the named instance does not exist then an exception is thrown. | |
void | GetNames (Names &names) const override |
Returns a vector of the names of the servers stored in the collection. | |
void | GetNamesAndStatuses (Names &names, Statuses &statuses) const override |
void | Start () override |
void | StartAcceptingConnections () override |
void | StopAcceptingConnections () override |
void | BeginShutdown () override |
Starts the shutdown process and returns immediately. | |
void | WaitForShutdownToComplete () override |
Initiates a shutdown (if one isn't already in progresss) and then waits for it to complete. Does not return until the shutdown has completed. | |
bool | WaitForShutdownToComplete (Milliseconds timeout) override |
Initiates a shutdown (if one isn't already in progresss) and then waits for the supplied number of milliseconds for it to complete. Returns true if the shutdown completed successfully before the timeout expired and false if it didn't. Note that EACH server in the collection is given the timeout to shutdown. The timeout does NOT apply to the collection as a whole. | |
void | ForceShutdown () override |
If a shutdown is hung due to sockets still being active then you can force a shutdown to complete by calling this function. Note: USE WITH CARE!!! The usual usage pattern is to call WaitForShutdownToComplete() with a timeout and if that fails then to call ForceShutdown() to allow the object in question to be destroyed (in general the object would call WaitForShutdownToComplete() in its destructor and hang there!). | |
Status | GetStatus () const override |
Returns the status of the collection. | |
bool | WaitForShutdownToComplete (Milliseconds timeout, INamedServerShutdownCallback &callback, void *pUserData) |
Initiates a shutdown (if one isn't already in progresss) and then waits for the supplied number of milliseconds for it to complete. Returns true if the shutdown completed successfully before the timeout expired and false if it didn't. Note that EACH server in the collection is given the timeout to shutdown. The timeout does NOT apply to the collection as a whole. Note that you are called back for each server that is shutting down via the supplied callback interface. | |
Static Public Member Functions | |
static JetByteTools::Core::_tstring | GetStatusAsString (Status status) |
typedef std::vector<JetByteTools::Core::_tstring> Names [inherited] |
typedef std::vector<IServerControl::Status> Statuses [inherited] |
enum Status [inherited] |
Creates an empty collection.
CNamedServerCollection | ( | const CNamedServerCollection & | rhs | ) |
~CNamedServerCollection | ( | ) | [override] |
CNamedServerCollection& operator= | ( | const CNamedServerCollection & | rhs | ) |
void AddServer | ( | const JetByteTools::Core::_tstring & | name, | |
IServerControl * | pServer | |||
) |
Adds an instance of IServerControl to the collection and takes ownership of the instance; it will be deleted when the collection is destroyed.
void AddServer | ( | const JetByteTools::Core::_tstring & | name, | |
IServerControl & | server | |||
) |
Adds an instance of IServerControl to the collection and does not take ownership of the instance.
IServerControl* RemoveServer | ( | const JetByteTools::Core::_tstring & | name | ) |
Locates an instance of IServerControl by name and removes it from the collection and returns it. If the instance was owned by the collection then it is no longer owned by the collection and the caller now owns the instance. Returns 0 if an instance of the supplied name does not exist.
void RemoveServers | ( | ) |
Removes all instances from the collection and destroys those instances that the collection owns.
void StartAcceptingConnections | ( | const Names & | serversToStart | ) |
void StopAcceptingConnections | ( | Names & | serversThatWereStopped | ) |
void StopTheseServersFromAcceptingConnections | ( | const Names & | serversToStop | ) |
IServerControl& GetServer | ( | const JetByteTools::Core::_tstring & | name | ) | const [override, virtual] |
Obtains a reference to an instance of IServerControl from the collection by name. If the named instance does not exist then an exception is thrown.
Implements IManageNamedServers.
void GetNames | ( | Names & | names | ) | const [override, virtual] |
Returns a vector of the names of the servers stored in the collection.
Implements IManageNamedServers.
Implements IManageNamedServers.
void Start | ( | ) | [override, virtual] |
Implements IServerControl.
void StartAcceptingConnections | ( | ) | [override, virtual] |
Implements IServerControl.
void StopAcceptingConnections | ( | ) | [override, virtual] |
Implements IServerControl.
void BeginShutdown | ( | ) | [override, virtual] |
void WaitForShutdownToComplete | ( | ) | [override, virtual] |
Initiates a shutdown (if one isn't already in progresss) and then waits for it to complete. Does not return until the shutdown has completed.
Implements IServerControl.
bool WaitForShutdownToComplete | ( | Milliseconds | timeout | ) | [override, virtual] |
Initiates a shutdown (if one isn't already in progresss) and then waits for the supplied number of milliseconds for it to complete. Returns true if the shutdown completed successfully before the timeout expired and false if it didn't. Note that EACH server in the collection is given the timeout to shutdown. The timeout does NOT apply to the collection as a whole.
Implements IServerControl.
void ForceShutdown | ( | ) | [override, virtual] |
If a shutdown is hung due to sockets still being active then you can force a shutdown to complete by calling this function. Note: USE WITH CARE!!! The usual usage pattern is to call WaitForShutdownToComplete() with a timeout and if that fails then to call ForceShutdown() to allow the object in question to be destroyed (in general the object would call WaitForShutdownToComplete() in its destructor and hang there!).
Implements IServerControl.
IServerControl::Status GetStatus | ( | ) | const [override, virtual] |
bool WaitForShutdownToComplete | ( | Milliseconds | timeout, | |
INamedServerShutdownCallback & | callback, | |||
void * | pUserData | |||
) |
Initiates a shutdown (if one isn't already in progresss) and then waits for the supplied number of milliseconds for it to complete. Returns true if the shutdown completed successfully before the timeout expired and false if it didn't. Note that EACH server in the collection is given the timeout to shutdown. The timeout does NOT apply to the collection as a whole. Note that you are called back for each server that is shutting down via the supplied callback interface.
_tstring GetStatusAsString | ( | Status | status | ) | [static, inherited] |