The C++ framework for developing highly scalable, high performance servers on Windows platforms.

CServerCollection Class Reference

Inheritance diagram for CServerCollection:
Collaboration diagram for CServerCollection:

List of all members.


Detailed Description

A class that implements a collection of instances of IServerControl and that allows you to control all of the instances as one.


Public Types

enum  Status {
  NotStarted, AcceptingConnections, Paused, ShuttingDown,
  Stopped, Indeterminate
}

Public Member Functions

 CServerCollection ()
 Creates an empty collection.
 CServerCollection (const CServerCollection &rhs)
 ~CServerCollection () override
CServerCollectionoperator= (const CServerCollection &rhs)
void AddServer (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 (IServerControl &server)
 Adds an instance of IServerControl to the collection and does not take ownership of the instance.
void RemoveServers ()
 Removes all instances from the collection and destroys those instances that the collection owns.
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 server.
bool WaitForShutdownToComplete (Milliseconds timeout, IServerShutdownCallback &callback, void *pUserData=nullptr)
 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)


Member Enumeration Documentation

enum Status [inherited]

Enumerator:
NotStarted 
AcceptingConnections 
Paused 
ShuttingDown 
Stopped 
Indeterminate 


Constructor & Destructor Documentation

Creates an empty collection.

CServerCollection ( const CServerCollection rhs  ) 

~CServerCollection (  )  [override]


Member Function Documentation

CServerCollection& operator= ( const CServerCollection rhs  ) 

void AddServer ( 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 ( IServerControl server  ) 

Adds an instance of IServerControl to the collection and does not take ownership of the instance.

void RemoveServers (  ) 

Removes all instances from the collection and destroys those instances that the collection owns.

void Start (  )  [override, virtual]

Implements IServerControl.

void StartAcceptingConnections (  )  [override, virtual]

Implements IServerControl.

void StopAcceptingConnections (  )  [override, virtual]

Implements IServerControl.

void BeginShutdown (  )  [override, virtual]

Starts the shutdown process and returns immediately.

Implements IServerControl.

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]

Returns the status of the server.

Implements IServerControl.

bool WaitForShutdownToComplete ( Milliseconds  timeout,
IServerShutdownCallback callback,
void *  pUserData = nullptr 
)

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]


Generated on Sun Sep 12 19:10:37 2021 for The Server Framework - v7.4 by doxygen 1.5.3