CC32WorkerThread Class Reference

class CC32WorkerThread : public CBase

Inherits from

Public Member Functions
~CC32WorkerThread()
voidCFBindMessageReceived(const CommsFW::TCFBindMsg &)
voidCFShutdownMessageReceived(const CommsFW::TCFShutdownMsg &)
voidCFUnbindMessageReceived(const CommsFW::TCFUnbindMsg &)
CC32Dealer *Dealer()
CC32Dealer &DealerByRef()
TBool DealerShutdownComplete()
voidDispatchL(const CommsFW::TCFMessage &, CommsFW::TWorkerId)
TBool IsMainThread()
voidMaybeTriggerThreadShutdownCallback()
CC32WorkerThread *NewL(CommsFW::TCFModuleInfo *)
voidOnDispatchLeave(const CommsFW::TCFMessage &, CommsFW::TWorkerId, TInt)
TBool PeerReachable(CommsFW::TWorkerId)
CC32Player *Player()
TBool PlayerShutdownComplete()
voidPostMessage(CommsFW::TWorkerId, CommsFW::TCFMessage &)
IMPORT_C TIntRunC32Thread(CommsFW::TCFModuleInfo *)
voidSessionShutdownComplete()
voidSetDealerShutdownComplete(TBool)
voidSetPlayerShutdownComplete(TBool)
voidSetShuttingDown()
TBool ShuttingDown()
IMPORT_C TIntThreadEntryPoint(TAny *)
voidTriggerThreadShutdownCallback()
CommsFW::TWorkerId WorkerId()
Protected Member Functions
CC32WorkerThread()
voidConstructL(CommsFW::TCFModuleInfo *)
Private Member Functions
voidDecProlongBindingLife()
TInt DecodePeerId(const CommsFW::TCFSubModuleAddress *, const CommsFW::TCFSubModuleAddress *, CommsFW::TWorkerId &)
voidDeleteHBufC8(TAny *)
voidDetermineRoleL(const TDesC8 &, TBool &, TBool &)
voidIncProlongBindingLife()
voidMaybeCompleteUnbinding(CommsFW::TWorkerId)
voidMaybeCompleteUnbindings()
voidProcessIniDataL()
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Private Attributes
CCommChannelHandler *iChannelHandler
CC32Dealer *iDealer
TBool iDealerShutdownComplete
CC32Player *iPlayer
TBool iPlayerShutdownComplete
TInt iProlongBindingLife
CommsFW::CCommsTransport *iTransport
CommsFW::TWorkerId iWorkerId
CC32WorkerRegister *iWorkerRegister
TBool iWorkerShuttingDown

Constructor & Destructor Documentation

CC32WorkerThread()

CC32WorkerThread()[protected]

~CC32WorkerThread()

~CC32WorkerThread()

Member Functions Documentation

CFBindMessageReceived(const CommsFW::TCFBindMsg &)

voidCFBindMessageReceived(const CommsFW::TCFBindMsg &aMsg)
Deals with binding requests from the Root Server. Note that although the Root Server allows multiple identical bindings C32 does not allow this and will panic if the binding already exists. Bindings are expressed in C32 by CCommsTransport. Since all sub-module names are unique across all C32 instances (they are the individual owning worker ID converted to text) they can be used here. I.e. the remote end sub-module is converted back to int and used to insert the CCommsTransport into an array in the position corresponding to the remote end sub-module name/number. As for responding to the bind request there are two cases:
  1. This worker is a "dumb" Player: Send bind response immediately.
    1. This worker is the Main thread: Send introduction messages to remote end and postpone bind response until introduction response messages have arrived back. CCommsTransport

Parameters

const CommsFW::TCFBindMsg & aMsg

CFShutdownMessageReceived(const CommsFW::TCFShutdownMsg &)

voidCFShutdownMessageReceived(const CommsFW::TCFShutdownMsg &aMsg)
A shutdown message can be of several types:
  1. EImmediate: We shutdown immediately even if leaking resources, although doing a best effort to cleanup. However, SymbianOS doesnt allow the server to gracefully terminate sessions so certain things cant be cleaned up.
    1. EOptional: Ignored.

    2. EGraceful: The module only unloads once no resources remain, which means for the Dealer no sessions and for the Player no subsessions. The shutdown request arrives after the unbind requests. CommsFW::TCFShutdownMsg CommsFW::TCFShutdownType CC32Dealer::ProcessShutdownRequest CC32Player::ProcessShutdownRequest CC32WorkerThread::SetShuttingDown CC32WorkerThread::MaybeTriggerThreadShutdownCallback

Parameters

const CommsFW::TCFShutdownMsg & aMsg

CFUnbindMessageReceived(const CommsFW::TCFUnbindMsg &)

voidCFUnbindMessageReceived(const CommsFW::TCFUnbindMsg &aMsg)
The unbind requests are only responded to once the channel is presumed to be idle:
  • for Dealers this means no sessions remain with subsessions on that Player

  • for Players this means no subsessions remain for that Dealer So the peer handler is marked as pending unbind but the unbind response is not sent back until both Dealer and Player (if any) confirm idleness, which has to be checked whenever closing sessions or subsessions. Perhaps this could/should switch to using ref counts? Once unbind is pending the Dealer refrains from creating any new subsessions which use it. CC32WorkerThread::MaybeCompleteUnbinding

Parameters

const CommsFW::TCFUnbindMsg & aMsg

ConstructL(CommsFW::TCFModuleInfo *)

voidConstructL(CommsFW::TCFModuleInfo *aModuleInfo)[protected]
The worker thread secondary construction will create the relevant Player/Dealer instances needed as well as the channel handler to the Root Server. If and only if it is the main thread it will also create the PitBoss.
Note:

If it has a Dealer and is not the main thread it is a WorkerDealer.

Parameters

CommsFW::TCFModuleInfo * aModuleInfo

Dealer()

CC32Dealer *Dealer()const [inline]

DealerByRef()

CC32Dealer &DealerByRef()const [inline]

DealerShutdownComplete()

TBool DealerShutdownComplete()const [inline]

DecProlongBindingLife()

voidDecProlongBindingLife()[private, inline]

iProlongBindingLife

DecodePeerId(const CommsFW::TCFSubModuleAddress *, const CommsFW::TCFSubModuleAddress *, CommsFW::TWorkerId &)

TInt DecodePeerId(const CommsFW::TCFSubModuleAddress *aSubModule1,
const CommsFW::TCFSubModuleAddress *aSubModule2,
CommsFW::TWorkerId &aPeerId
)[private]

Parameters

const CommsFW::TCFSubModuleAddress * aSubModule1
const CommsFW::TCFSubModuleAddress * aSubModule2
CommsFW::TWorkerId & aPeerId

DeleteHBufC8(TAny *)

voidDeleteHBufC8(TAny *aHBufC)[private, static]

Parameters

TAny * aHBufC

DetermineRoleL(const TDesC8 &, TBool &, TBool &)

voidDetermineRoleL(const TDesC8 &aIniData,
TBool &aIsDealer,
TBool &aIsPlayer
)[private]

Determine from inidata whether this worker is Dealer, Player or both.

Parameters

const TDesC8 & aIniData
TBool & aIsDealer
TBool & aIsPlayer

DispatchL(const CommsFW::TCFMessage &, CommsFW::TWorkerId)

voidDispatchL(const CommsFW::TCFMessage &aMessage,
CommsFW::TWorkerIdaSenderId
)

Parameters

const CommsFW::TCFMessage & aMessage
CommsFW::TWorkerId aSenderId

IncProlongBindingLife()

voidIncProlongBindingLife()[private, inline]

iProlongBindingLife

IsMainThread()

TBool IsMainThread()const [inline]

Use this to discover whether this Worker Thread is EMainThread ("C32_Main") which is the main Dealer. TWorkerThreadInfo

MaybeCompleteUnbinding(CommsFW::TWorkerId)

voidMaybeCompleteUnbinding(CommsFW::TWorkerIdaWorker)[private]

Parameters

CommsFW::TWorkerId aWorker

MaybeCompleteUnbindings()

voidMaybeCompleteUnbindings()[private]

Can be called at any time, will poll all peer handlers for unbind "readiness" and make sure they complete the unbind if possible. CC32WorkerThread::MaybeCompleteUnbinding

MaybeTriggerThreadShutdownCallback()

voidMaybeTriggerThreadShutdownCallback()

NewL(CommsFW::TCFModuleInfo *)

CC32WorkerThread *NewL(CommsFW::TCFModuleInfo *aModuleInfo)[static]

Parameters

CommsFW::TCFModuleInfo * aModuleInfo

OnDispatchLeave(const CommsFW::TCFMessage &, CommsFW::TWorkerId, TInt)

voidOnDispatchLeave(const CommsFW::TCFMessage &aMessage,
CommsFW::TWorkerIdaSenderId,
TIntaFirstDispatchLeaveReason
)

Parameters

const CommsFW::TCFMessage & aMessage
CommsFW::TWorkerId aSenderId
TInt aFirstDispatchLeaveReason

PeerReachable(CommsFW::TWorkerId)

TBool PeerReachable(CommsFW::TWorkerIdaPeerId)const [inline]

Parameters

CommsFW::TWorkerId aPeerId

Player()

CC32Player *Player()const [inline]

PlayerShutdownComplete()

TBool PlayerShutdownComplete()const [inline]

PostMessage(CommsFW::TWorkerId, CommsFW::TCFMessage &)

voidPostMessage(CommsFW::TWorkerIdaWorkerId,
CommsFW::TCFMessage &aMessage
)

Parameters

CommsFW::TWorkerId aWorkerId
CommsFW::TCFMessage & aMessage

ProcessIniDataL()

voidProcessIniDataL()[private]

RunC32Thread(CommsFW::TCFModuleInfo *)

IMPORT_C TIntRunC32Thread(CommsFW::TCFModuleInfo *aModuleInfo)[static]

The comm server thread.

Parameters

CommsFW::TCFModuleInfo * aModuleInfo

SessionShutdownComplete()

voidSessionShutdownComplete()

SetDealerShutdownComplete(TBool)

voidSetDealerShutdownComplete(TBoolaComplete)

Parameters

TBool aComplete

SetPlayerShutdownComplete(TBool)

voidSetPlayerShutdownComplete(TBoolaComplete)

Parameters

TBool aComplete

SetShuttingDown()

voidSetShuttingDown()

ShuttingDown()

TBool ShuttingDown()const

ThreadEntryPoint(TAny *)

IMPORT_C TIntThreadEntryPoint(TAny *aArg)[static]

This is the main thread function used by the RootServer when creating a new C32 thread. The RootServer will know the DLL ordinal for it, as specified in the .CMI file, and this is where an C32 instance starts and ends operation (unless it PANICs). CommsFW::TCFModuleInfoThe C32 thread. This is where control will resume when the RootServer starts a C32 instance. This function creates the worker thread object and starts the active scheduler.

Parameters

TAny * aArgWill be the module info structure from the RootServer.

TriggerThreadShutdownCallback()

voidTriggerThreadShutdownCallback()

WorkerId()

CommsFW::TWorkerId WorkerId()const [inline]

Member Data Documentation

CCommChannelHandler * iChannelHandler

CCommChannelHandler *iChannelHandler[private]

This is the handler used for bi-directional communication with the Root Server.

CC32Dealer * iDealer

CC32Dealer *iDealer[private]

TBool iDealerShutdownComplete

TBool iDealerShutdownComplete[private]

Set by the Dealer instance to signal to the Worker Thread that it has finished with the shutdown bookkeeping and is ready to be deleted. This essentially means no sessions remain.

CC32Player * iPlayer

CC32Player *iPlayer[private]

TBool iPlayerShutdownComplete

TBool iPlayerShutdownComplete[private]

Set by the Player instance to signal to the Worker Thread that it has finished with the shutdown bookkeeping and is ready to be deleted.

TInt iProlongBindingLife

TInt iProlongBindingLife[private]

If the value of this TInt is larger than 0 any unbind requests will not be served, but postponed until iProlongBindingLife is 0. This is to ensure that if e.g. a TWorkerMsg::ECleanupDeadPeer or TPlayerMsg::ESessionClose is received they will be fully served before completing any unbind and thus deleting channel handlers.

CommsFW::CCommsTransport * iTransport

CommsFW::CCommsTransport *iTransport[private]

CommsFW::TWorkerId iWorkerId

CommsFW::TWorkerId iWorkerId[private]

Indentification of this thread. No other instance must have the same id. TWorkerThreadInfo

CC32WorkerRegister * iWorkerRegister

CC32WorkerRegister *iWorkerRegister[private]

TBool iWorkerShuttingDown

TBool iWorkerShuttingDown[private]

Set when a CommsFW::TCFShutdownMsg is received from the Root Server.