1 / 7

活动对象

活动对象. 主要内容. 活动对象机制 活动对象的使用 用活动对象处理复杂事务. 活动对象机制. 活动对象框架 活动对象调度器 CActiveScheduler class CActiveScheduler : public CBase { friend class CActiveSchedulerWait; public: struct TLoop; typedef TLoop* TLoopOwner; public: IMPORT_C CActiveScheduler(); IMPORT_C ~CActiveScheduler();

swain
Download Presentation

活动对象

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 活动对象

  2. 主要内容 • 活动对象机制 • 活动对象的使用 • 用活动对象处理复杂事务

  3. 活动对象机制 • 活动对象框架 • 活动对象调度器CActiveScheduler class CActiveScheduler : public CBase { friend class CActiveSchedulerWait; public: struct TLoop; typedef TLoop* TLoopOwner; public: IMPORT_C CActiveScheduler(); IMPORT_C ~CActiveScheduler(); IMPORT_C static void Install(CActiveScheduler* aScheduler); IMPORT_C static void Add(CActive* aActive); IMPORT_C static void Start(); IMPORT_C static void Stop(); ... ... };

  4. 活动对象机制 • 活动对象框架 • 活动对象类CActive • class CActive : public CBase • { • public: • IMPORT_C ~CActive(); • IMPORT_C void Cancel(); • ... ... • protected: • IMPORT_C CActive(TInt aPriority); • IMPORT_C void SetActive(); • virtual void DoCancel() =0; • virtual void RunL() =0; • IMPORT_C virtual TInt RunError(TInt aError); • public: • TRequestStatus iStatus; • };

  5. 活动对象机制 • 活动对象的生命周期及操作顺序

  6. 活动对象的使用 • 实现活动对象的必要步骤 • (1)从CActive类派生活动对象类 • (2)实现活动对象类的构造函数 • (3)实现活动对象的二阶段构造函数ConstructL() • (4)实现CActive类的三个虚函数RunL()、DoCancel()、RunError() • (5)实现活动对象的析构函数

  7. 用活动对象处理复杂事务 • 活动对象的RunL()方法不能长时间占用CPU • 把复杂大任务分割成许多小任务进行处理

More Related