src_oss_os_kernelhwsrv\sf\os\kernelhwsrv\kernel\eka\euser\cbase\ub_act.cpp
EXPORT_C void CAsyncOneShot::Call()
/**
Queues this active object to be run once.
@panic E32USER-CBase 2 In debug builds only, if this active object has not
already been added to the active scheduler.
*/
{
__ASSERT_DEBUG(IsAdded(),Panic(ECAsyncOneShotNotAdded));
TRequestStatus *pS=(&iStatus);
iStatus = KRequestPending;
SetActive();
iThread.RequestComplete(pS,0);
}
EXPORT_C void CAsyncOneShot::DoCancel()
/**
Implements cancellation of an outstanding request.
The class provides an empty implementation.
This is called by the destructor.
*/
{
// Empty
}
EXPORT_C CAsyncOneShot::CAsyncOneShot(TInt aPriority)
:CActive(aPriority)
/**
Constructor taking a priority value.
Specifically, the constructor:
1. sets this active object's priority value
2. opens a handle to the current thread to ensure that the thread cannot be
closed until this CAsyncOneShot object is destroyed
3. adds this active object to the current active scheduler.
@param aPriority The active object priority value. CActive::TPriority defines
a standard set of priorities.
@panic E32USER-CBase 93 if the attempt to open a handle to the current thread
fails.
*/
{
Setup();
}
void CAsyncOneShot::Setup()
//
// ensures that we are added to the Scheduler.
//
{
// No error checking was done initially. As this function is called from
// the c'tor, there is no way to fix it properly without breaking BC. So
// we panic if something goes wrong (should only happen in extreme
// circumstances if the kernel heap is exhausted or heavily fragmented).
__ASSERT_ALWAYS(iThread.Duplicate(RThread()) == KErrNone, Panic(EAsyncOneShotSetupFailed));
// Add ourself to the current active scheduler
// This is because we might be being used as an inter thread call
// we need to make sure that we're on the correct scheduler for
// the RThread were going to duplicate.
CActiveScheduler::Add(this);
}
EXPORT_C CAsyncOneShot::~CAsyncOneShot()
/**
Frees resources prior to destruction.
Specifically, it closes the handle to the current thread.
@see CActive::~CActive
*/
{
Cancel();
iThread.Close();
}
EXPORT_C CAsyncCallBack::CAsyncCallBack(TInt aPriority)
: CAsyncOneShot(aPriority), iCallBack(NULL)
/**
Constructor taking a priority value.
Specifically, the constructor sets this active object's priority value through
a call to the base class constructor in its ctor list.
No call back is set, which means that it must be set subsequently through
a call to the Set() function.
@param aPriority The active object priority value. CActive::TPriority defines
a standard set of priorities.
@see CAsyncCallBack::Set
*/
{
}
EXPORT_C CAsyncCallBack::CAsyncCallBack(const TCallBack& aCallBack, TInt aPriority)
: CAsyncOneShot(aPriority), iCallBack(aCallBack)
/**
Constructor taking a priority value and a callback.
Specifically, the constructor:
1. sets this active object's priority value through a call to the base class
constructor in its ctor list
2. sets the callback; the function encapsulated by the callback is called when
this active object is scheduled to run.
@param aCallBack A reference to a callback object encapsulating a function
which is called when this active object is ready to run.
The constructor takes a copy of this callback object, which
means that it can be safely discarded after construction.
@param aPriority The active object priority value.
*/
{
}
EXPORT_C CAsyncCallBack::~CAsyncCallBack()
/**
Destructor.
*/
{
}
EXPORT_C void CAsyncCallBack::CallBack()
/**
Queues this active object to be run, if it is not already queued.
*/
{
if (!IsActive())
Call();
}
EXPORT_C void CAsyncCallBack::Set(const TCallBack& aCallBack)
/**
Sets the call back.
@param aCallBack A reference to a callback object encapsulating a function
which is called when this active object is ready to run.
@panic E32USER-CBase 1 if the active object is currently active.
*/
{
__ASSERT_ALWAYS(!IsActive(), Panic(ECAsyncCBIsActive));
iCallBack = aCallBack;
}
void CAsyncCallBack::RunL()
/**
Calls the callback function.
@see TCallBack::CallBack
*/
{
iCallBack.CallBack();
}
symbian_src\sf\app\files\filemanager\App\src
void CFileManagerAppUi::StopIRReceive()
{
FUNC_LOG
if ( iIRReceiver )
{
iIRReceiver->StopReceiving();
delete iIRDeleteCB;
iIRDeleteCB = NULL;
iIRDeleteCB = new CAsyncCallBack(
TCallBack( DeleteIRReceiveCB, this ),
CActive::EPriorityStandard );
if ( iIRDeleteCB )
{
iIRDeleteCB->CallBack();
}
}
}
// ------------------------------------------------------------------------------
// CFileManagerAppUi::DeleteIRReceiveCB
//
// ------------------------------------------------------------------------------
//
TInt CFileManagerAppUi::DeleteIRReceiveCB( TAny* aPtr )
{
FUNC_LOG
CFileManagerAppUi* self = static_cast< CFileManagerAppUi* >( aPtr );
delete self->iIRReceiver;
self->iIRReceiver = NULL;
delete self->iIRDeleteCB;
self->iIRDeleteCB = NULL;
return KErrNone;
}