Main Page | Class Hierarchy | Class List | File List | Class Members

Manager Class Reference

#include <main.h>

Collaboration diagram for Manager:

[legend]
List of all members.

Public Member Functions

 Manager ()
 ~Manager ()
PSafePtr< TcpConnectionGetConnectionWithLock (const PString &token, PSafetyMode mode=PSafeReadWrite)
void RemoveNode (const PString &token)
void WaitForIncoming ()
PString ProcessMessagesName ()
void AppendRunning (PSafePtr< TcpConnection > conn, const PString &id)
void AppendDead (PSafePtr< TcpConnection > conn)
void QuitNow ()
void StopIncomingConnections ()
void GetListConnectedNodes (PStringArray &nodes)
BOOL KeepRunning ()
void OnReleased (TcpConnection &connection)
void WaitForEmpty ()
void GetStatus (PStringStream &status)
PString GetNextBogusId ()

Protected Member Functions

virtual void DoQuitNow (PThread &, INT)

Protected Attributes

Manager::ConnectionDict connectionsActive
PTCPSocket listener
PAtomicInteger bogusCount
PAtomicInteger connectionCount
TcpConnectionList availableTcpConnections
BOOL keepRunning
BOOL isQuitting
PMutex quitNowMutex

Classes

class  ConnectionDict

Detailed Description

This handles the list of known connections, and waits for new incoming connections. It will process the commands "list" and "quitnow", to provide additional functionality for remote nodes


Constructor & Destructor Documentation

Manager::Manager  ) 
 

Constructor

Manager::~Manager  ) 
 

Destructor


Member Function Documentation

void Manager::AppendDead PSafePtr< TcpConnection conn  ) 
 

Append this connction to connectionsActive. We do not know what label to use on this connection, so we have to make up a label. We label it immediately as bogus, call manager.RemoveNode(), and let the garbage collector kill it

void Manager::AppendRunning PSafePtr< TcpConnection conn,
const PString &  id
 

Append this connction to connectionsActive, cause it is a valid and running TcpConnection

void Manager::DoQuitNow PThread &  ,
INT 
[protected, virtual]
 

This does the work of deleting all active connections. Using a thread to do the work saves a deadlock from an active connection trying to enact a close down.

PSafePtr<TcpConnection> Manager::GetConnectionWithLock const PString &  token,
PSafetyMode  mode = PSafeReadWrite
[inline]
 

Find a connection that uses the specified token. This searches the list of TcpConnections for the connection that contains the token as provided

Parameters:
token  Token to identify connection
mode  Mode of access

void Manager::GetListConnectedNodes PStringArray &  nodes  ) 
 

Retrieve the list of connected nodes - which is the keys they are using to identify themselves

PString Manager::GetNextBogusId  ) 
 

Report the next string to use for creating a bogus id. This is used on those TcpConnection instances that do not start up correctly

void Manager::GetStatus PStringStream &  status  ) 
 

Report the status etc of this Manager class. List sizes, etc

BOOL Manager::KeepRunning  )  [inline]
 

Report if the manager is to continue processing incoming connection requests

void Manager::OnReleased TcpConnection connection  ) 
 

Callback for removing a connection from the list of active connections

PString Manager::ProcessMessagesName  ) 
 

Return a nnew unique name to be assigned to each neew process messages thread for a connection

void Manager::QuitNow  ) 
 

Cause a shutdown of the whole thing

void Manager::RemoveNode const PString &  token  ) 
 

Remove the connection with the specified token

void Manager::StopIncomingConnections  ) 
 

StopAll incoming connect requests, by closing the socket on port 5000

void Manager::WaitForEmpty  ) 
 

Wait for the lists in this class to go empty

void Manager::WaitForIncoming  ) 
 

Wait for incoming connections here. On receiving a connection, act on it.


Member Data Documentation

TcpConnectionList Manager::availableTcpConnections [protected]
 

A class that manages the list of available TcpConnection threads

PAtomicInteger Manager::bogusCount [protected]
 

The integer used to create unique id's for the dead TcpConnections

PAtomicInteger Manager::connectionCount [protected]
 

The count of all threads that have beeen spawned to process messages

Manager::ConnectionDict Manager::connectionsActive [protected]
 

The thread safe list of connections that we manage

BOOL Manager::isQuitting [protected]
 

Flag to indicate we are in close down mode

BOOL Manager::keepRunning [protected]
 

Flag that specifies that this Manager is to continue processing commands

PTCPSocket Manager::listener [protected]
 

The socket that we listen for incoming connections on

PMutex Manager::quitNowMutex [protected]
 

Mutex to protect access tothe close down flag


The documentation for this class was generated from the following files:
Generated on Thu Apr 19 00:03:11 2007 for SSServer, or Sofa Switch Server by  doxygen 1.4.4