CAsyncCallBack

 

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;
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值