Den::CCommonPitBoss Class Reference
class Den::CCommonPitBoss : public CBase
|
The PitBoss has responsibility for global resources and gross error handling (panics, etc). The Pit Boss thread must be started by the Configurator before any worker threads. The instance loading it must be the only one having the WorkerId 0 (TWorkerThreadInfo::EMainThread). The PitBoss has two main responsibilities:
-
Maintain global data structures, accessible to all Workers to which the PitBoss pointer is published (through the TWorkerMainIntroductionMsg). Mostly the workers will access this data using PitBoss access functions which are thread-safe, taking special measures to guarantee this where needed.
-
Manage Worker thread start and death: Registering Workers and do a best effort cleanup if they die due to some error condition.
Apart from these, the PitBoss also provides some minor but important services. For example as all instances can have their own heap sometimes it happens that one Worker needs to do something that might cause allocation or freeing on another workers heap, such as inserting a sub-session into a Dealers session. So the PitBoss offer a function that can determine whether a different heap is needed (maybe the two workers have different heaps, maybe they share one heap) and does the switch. It also has
AddSubSession()
and
RemoveSubSession()
methods used by the Player, assuring this happens on the right heap.
Nested Classes and Structures
Public Member Functions
|
|
~CCommonPitBoss
()
|
void
|
AddPendingIntroductionResponse
()
|
IMPORT_C
TInt
|
AddSubSession
(
CWorkerSubSession
*,
CWorkerSession
*,
TInt
&)
|
IMPORT_C void
|
BindMessageReceived
(const
CommsFW::TCFModuleName
&,
CommsFW::TWorkerId
)
|
IMPORT_C void
|
BroadcastConfigurationComplete
(
TConfigurationCompletionType
)
|
void
|
CompleteWorkerThreadCleanup
(
CommsFW::TWorkerId
)
|
IMPORT_C void
|
ConstructL
()
|
CCommonDealer
*
|
Dealer
(const
TWorkerThreadRegister
&)
|
CCommonDealer
*
|
Dealer
(
CommsFW::TWorkerId
)
|
IMPORT_C
TInt
|
DoCreateRedShirt
(
RThread
&,
CommsFW::TWorkerId
,
CCommonWorkerThread
&)
|
void
|
DoOnCPMsConfigured
()
|
void
|
DoOnPeerDeath
(
CommsFW::TWorkerId
)
|
IMPORT_C
TBool
|
FindOptimalDealer
(
CommsFW::TWorkerId
, CCommonWorkerDealer *&)
|
void
|
FreeWorkerReferences
(
CommsFW::TWorkerId
)
|
IMPORT_C
CCommonDealer
*
|
GetDealer
(
CommsFW::TWorkerId
)
|
IMPORT_C
CCommonPlayer
*
|
GetPlayer
(const
TWorkerIntroductionMsg
&)
|
IMPORT_C void
|
HandleWorkerCleanupCompletionByPeer
(
CommsFW::TWorkerId
,
CommsFW::TWorkerId
)
|
IMPORT_C
TBool
|
IsShuttingDown
()
|
IMPORT_C
RAllocator
*
|
MaybeSwitchHeap
(
CommsFW::TWorkerId
)
|
IMPORT_C
TBool
|
ModuleConfigurationComplete
()
|
TInt
|
NextSessionId
()
|
TSessionUniqueId
|
NextSessionUniqueId
()
|
TSubSessionUniqueId
|
NextSubSessionUniqueId
()
|
IMPORT_C void
|
OnCPMsConfigured
()
|
IMPORT_C void
|
OnPeerDeath
(
CommsFW::TWorkerId
)
|
CCommonWorkerThread
*
|
OwnerThread
()
|
IMPORT_C void
|
PeerWorkerExiting
(
CommsFW::TWorkerId
)
|
CCommonPlayer
*
|
Player
(const
TWorkerThreadRegister
&)
|
CCommonPlayer
*
|
Player
(
CommsFW::TWorkerId
)
|
IMPORT_C void
|
PostMessage
(
CommsFW::TWorkerId
,
CommsFW::TCFMessage
&)
|
IMPORT_C void
|
ProcessWorkerIntroductionL
(const
TWorkerIntroductionMsg
&)
|
TUid
|
PropertyKey
()
|
IMPORT_C const
RThread
&
|
RThreadRef
(
CommsFW::TWorkerId
)
|
void
|
ReleaseImmediateShutdownPresent
()
|
void
|
RemovePendingIntroductionResponse
()
|
IMPORT_C void
|
RemoveSubSession
(
TInt
,
CWorkerSession
*)
|
IMPORT_C
TBool
|
ResolvePlayerRoleToId
(const
TPlayerRole
&,
CommsFW::TWorkerId
&)
|
IMPORT_C
TBool
|
ResolveWorkerNameToId
(const
TDesC8
&,
CommsFW::TWorkerId
&)
|
IMPORT_C void
|
SessionShutdownComplete
()
|
IMPORT_C void
|
SetFailNextForAllHeaps
(
TInt
)
|
void
|
SetImmediateShutdownPresent
()
|
void
|
ShutdownIfReady
()
|
void
|
StartShutdown
()
|
TBool
|
TestAndLockImmediateShutdownPresent
()
|
IMPORT_C
TBool
|
TestFailNextForAllHeaps
()
|
IMPORT_C
TBool
|
TestImmediateShutdownPresent
()
|
CWorkerDataGlobals
&
|
WorkerDataGlobals
()
|
IMPORT_C
TBool
|
WorkerExists
(
CommsFW::TWorkerId
)
|
CCommonWorkerThread
&
|
WorkerThread
()
|
Constructor & Destructor Documentation
CCommonPitBoss(CCommonWorkerThread *)
~CCommonPitBoss()
IMPORT_C
|
~CCommonPitBoss
|
(
|
)
|
|
Member Functions Documentation
AddPendingIntroductionResponse()
void
|
AddPendingIntroductionResponse
|
(
|
)
|
|
AddSubSession(CWorkerSubSession *, CWorkerSession *, TInt &)
Called by any Player/thread to add a sub-session to a session. It will switch the local heap to that of the peer before performing operations on the session pointer. It is essential that the session lock is used around this call.
CSubSessionIx::Lock
CSubSessionIx::UnLock
BindMessageReceived(const CommsFW::TCFModuleName &, CommsFW::TWorkerId)
BroadcastConfigurationComplete(TConfigurationCompletionType)
IMPORT_C void
|
BroadcastConfigurationComplete
|
(
|
TConfigurationCompletionType
|
aType
|
)
|
|
Parameters
TConfigurationCompletionType
aType
|
|
CompleteWorkerThreadCleanup(CommsFW::TWorkerId)
void
|
CompleteWorkerThreadCleanup
|
(
|
CommsFW::TWorkerId
|
aWorkerId
|
)
|
|
Parameters
CommsFW::TWorkerId
aWorkerId
|
|
ConstructL()
IMPORT_C void
|
ConstructL
|
(
|
)
|
|
Dealer(const TWorkerThreadRegister &)
Dealer(CommsFW::TWorkerId)
Parameters
CommsFW::TWorkerId
aWorkerId
|
|
DoCreateRedShirt(RThread &, CommsFW::TWorkerId, CCommonWorkerThread &)
DoFreeWorkerReferences(CommsFW::TWorkerId)
void
|
DoFreeWorkerReferences
|
(
|
CommsFW::TWorkerId
|
aWorkerId
|
)
|
[protected, pure virtual]
|
Parameters
CommsFW::TWorkerId
aWorkerId
|
|
DoOnCPMsConfigured()
void
|
DoOnCPMsConfigured
|
(
|
)
|
[pure virtual]
|
DoOnPeerDeath(CommsFW::TWorkerId)
void
|
DoOnPeerDeath
|
(
|
CommsFW::TWorkerId
|
aWorkerId
|
)
|
[pure virtual]
|
Parameters
CommsFW::TWorkerId
aWorkerId
|
|
DoProcessWorkerIntroductionL(const TWorkerIntroductionMsg &)
FindOptimalDealer(CommsFW::TWorkerId, CCommonWorkerDealer *&)
IMPORT_C
TBool
|
FindOptimalDealer
|
(
|
CommsFW::TWorkerId
|
aWorkerId,
|
|
CCommonWorkerDealer *&
|
aDealer
|
|
)
|
|
Parameters
CommsFW::TWorkerId
aWorkerId
|
|
CCommonWorkerDealer *& aDealer
|
|
FreeWorkerReferences(CommsFW::TWorkerId)
void
|
FreeWorkerReferences
|
(
|
CommsFW::TWorkerId
|
aWorkerId
|
)
|
|
Parameters
CommsFW::TWorkerId
aWorkerId
|
|
GetDealer(CommsFW::TWorkerId)
GetPlayer(const TWorkerIntroductionMsg &)
HandleWorkerCleanupCompletionByPeer(CommsFW::TWorkerId, CommsFW::TWorkerId)
IMPORT_C void
|
HandleWorkerCleanupCompletionByPeer
|
(
|
CommsFW::TWorkerId
|
aWorkerId,
|
|
CommsFW::TWorkerId
|
aPeerId
|
|
)
|
|
Parameters
CommsFW::TWorkerId
aWorkerId
|
|
CommsFW::TWorkerId
aPeerId
|
|
IsShuttingDown()
IMPORT_C
TBool
|
IsShuttingDown
|
(
|
)
|
const
|
MaybeSwitchHeap(CommsFW::TWorkerId)
IMPORT_C
RAllocator
*
|
MaybeSwitchHeap
|
(
|
CommsFW::TWorkerId
|
aForeignWorkerId
|
)
|
|
Parameters
CommsFW::TWorkerId
aForeignWorkerId
|
|
ModuleConfigurationComplete()
IMPORT_C
TBool
|
ModuleConfigurationComplete
|
(
|
)
|
const
|
NextSessionUniqueId()
TSessionUniqueId
|
NextSessionUniqueId
|
(
|
)
|
[inline]
|
NextSubSessionUniqueId()
TSubSessionUniqueId
|
NextSubSessionUniqueId
|
(
|
)
|
[inline]
|
OnCPMsConfigured()
IMPORT_C void
|
OnCPMsConfigured
|
(
|
)
|
|
The PitBoss monitors the Comms Configurator sequence level and when the core components have been configured (this includes ESock) this method is called to delete any data structures used only during startup of ESock. CConfigurationLevelMonitor CPitBoss::iPendingIntroResponses
OnPeerDeath(CommsFW::TWorkerId)
IMPORT_C void
|
OnPeerDeath
|
(
|
CommsFW::TWorkerId
|
aWorkerId
|
)
|
|
Parameters
CommsFW::TWorkerId
aWorkerId
|
|
PeerWorkerExiting(CommsFW::TWorkerId)
IMPORT_C void
|
PeerWorkerExiting
|
(
|
CommsFW::TWorkerId
|
aWorker
|
)
|
|
Parameters
CommsFW::TWorkerId
aWorker
|
|
Player(const TWorkerThreadRegister &)
Player(CommsFW::TWorkerId)
Parameters
CommsFW::TWorkerId
aWorkerId
|
|
PostMessage(CommsFW::TWorkerId, CommsFW::TCFMessage &)
ProcessWorkerIntroductionL(const TWorkerIntroductionMsg &)
Used during binding when the PitBoss receives a introduction response message from a worker. The PitBoss will set-up housekeeping datastructures for the worker and add the supported protocols to its list of protocol pairings. TWorkerMsg::EMainIntroductionResp
PropertyKey()
TUid
|
PropertyKey
|
(
|
)
|
[inline]
|
RThreadRef(CommsFW::TWorkerId)
IMPORT_C const
RThread
&
|
RThreadRef
|
(
|
CommsFW::TWorkerId
|
aWorkerId
|
)
|
const
|
Parameters
CommsFW::TWorkerId
aWorkerId
|
|
ReleaseImmediateShutdownPresent()
void
|
ReleaseImmediateShutdownPresent
|
(
|
)
|
const
|
RemovePendingIntroductionResponse()
void
|
RemovePendingIntroductionResponse
|
(
|
)
|
|
RemoveSubSession(TInt, CWorkerSession *)
Called by any Player/thread to remove a sub-session from a session. It will switch the local heap to that of the peer before performing operations on the session pointer. It is essential that the session lock is used around this call.
CSubSessionIx::Lock
CSubSessionIx::UnLock
ResolvePlayerRoleToId(const TPlayerRole &, CommsFW::TWorkerId &)
IMPORT_C
TBool
|
ResolvePlayerRoleToId
|
(
|
const
TPlayerRole
&
|
aRoleId,
|
|
CommsFW::TWorkerId
&
|
aWorkerId
|
|
)
|
const
|
Resolve a PlayerRole to its thread id (module names are far less volatile than thread assignments which in the future may become highly dynamic. So module names are used to couple tier ids to threads
Parameters
const
TPlayerRole
& aRoleId
|
|
CommsFW::TWorkerId
& aWorkerId
|
|
ResolveWorkerNameToId(const TDesC8 &, CommsFW::TWorkerId &)
IMPORT_C
TBool
|
ResolveWorkerNameToId
|
(
|
const
TDesC8
&
|
aWorkerName,
|
|
CommsFW::TWorkerId
&
|
aWorkerId
|
|
)
|
const
|
Resolve a Worker thread's CFModule name to its thread id (module names are far less volatile than thread assignments which in the future may become highly dynamic. So module names are used to couple tier ids to threads
Parameters
const
TDesC8
& aWorkerName
|
|
CommsFW::TWorkerId
& aWorkerId
|
|
SessionShutdownComplete()
IMPORT_C void
|
SessionShutdownComplete
|
(
|
)
|
|
SetFailNextForAllHeaps(TInt)
IMPORT_C void
|
SetFailNextForAllHeaps
|
(
|
TInt
|
aFailNext
|
)
|
|
SetImmediateShutdownPresent()
void
|
SetImmediateShutdownPresent
|
(
|
)
|
|
TestAndLockImmediateShutdownPresent()
TBool
|
TestAndLockImmediateShutdownPresent
|
(
|
)
|
const
|
Immediate shutdowns expose a number of additional race risks; in the face of one happening to any thread at all we stop attempting certain kinds of cleanup. This should be acceptable behaviour since at it will be the whole of ESock shutting down. To avoid races between the testing and setting of this state, testing for it gains a lock which must be explicitly released. CPitBoss::ReleaseImmediateShutdownPresent()
TestFailNextForAllHeaps()
IMPORT_C
TBool
|
TestFailNextForAllHeaps
|
(
|
)
|
const
|
TestImmediateShutdownPresent()
IMPORT_C
TBool
|
TestImmediateShutdownPresent
|
(
|
)
|
const
|
Tests whether immediate shutdown is signaled. This function does not lock and is used where this knowledge is desired but no action is taken that might race with other threads. CPitBoss::TestAndLockImmediateShutdownPresent() CPitBoss::ReleaseImmediateShutdownPresent()
WorkerExists(CommsFW::TWorkerId)
IMPORT_C
TBool
|
WorkerExists
|
(
|
CommsFW::TWorkerId
|
aId
|
)
|
const
|
Member Data Documentation
CConfigurationLevelMonitor * iConfLevelMonitor
CConfigurationLevelMonitor *
|
iConfLevelMonitor
|
[protected]
|
Monitor configuration level to know when it is safe to delete data used solely during startup/binding. Note that if we should support loading new Socket Server modules at run time, sometime after system start, this will need to be changed so the list is always available to new modules.
RForsakenHeapList
iForsakenHeapList
RWorkerLock
iImmediateShutdownLock
This is used by Worker threads (as well as ESock_Main) during immediate shutdown. As a Worker could potentially delete a sub-session at the same time as the Dealer trying to mark it orphaned, these two operations need to be protected during immediate shutdown (but not normally).
TBool
iImmediateShutdownMark
TBool
|
iImmediateShutdownMark
|
[protected]
|
Set ETrue when immediate shutdown is received from the RootServer.
TUint
iNextUniqueId
TUint
|
iNextUniqueId
|
[protected]
|
Session/subsession unique id counter. This value represents a next (free) id that will be assigned to a newly created
CWorkerSubSession
object.
CCommonWorkerThread * iOwnerThread
TBool
iPeerShutdownComplete
TBool
|
iPeerShutdownComplete
|
[protected]
|
Set ETrue when all Worker threads have finished tidying up during a shut down procedure. The ESock_Main instance will only shut down when this is ETrue.
TInt
iPendingIntroResponses
TInt
|
iPendingIntroResponses
|
[protected]
|
Incremented when a request to bind to another instance has been received and decremented when a binding is complete. When the reference configurator configuration level have reached the point signifying that all core components have been configured and this TInt is 0, it is safe to delete data structures used only during startup. OnCoreComponentsConfigured()
TUid
iPropertyKey
TUid
|
iPropertyKey
|
[protected]
|
TBool
iSessionShutdownComplete
TBool
|
iSessionShutdownComplete
|
[protected]
|
Set ETrue when immediate shutdown is received by ESock_Main from the RootServer or if optional/graceful shutdown has been received at some point and the last session is closed.
TBool
iShuttingDown
TBool
|
iShuttingDown
|
[protected]
|
ETrue if the PitBoss is in the process of shutting down. Set when optional or graceful shutdown is received by ESock_Main from the RootServer.
CWorkerDataGlobals * iWorkerDataGlobals
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.