SophiaFramework UNIVERSE 5.3 |
The SFXTask class is used to deal with a task, that is, callback that will be called in the next event loop. This class used mainly to implement cooperative multi-task processing.
The method to use the SFXTask class is as follows:
Internal implementation | |
---|---|
The SFXTask class is implemented by using the SFXCallback class. In the internal implementaion, the BREW API ISHELL_Resume function is used to schedule a task, i.e., register a callback, |
class MyClass { private: SFXTimer _task; public: Void Function(Void); XALLBACK_DECLARE_SFXTASK(OnTask) }; Void MyClass::Function(Void) { ... // set information necessary to schedule the task // * set the OnTask function and data passed to the OnTask function _task.Set(XALLBACK_INTERNAL(OnTask)); /// schedule the task _task.Schedule(); if (error != SFERR_NO_ERROR) { // if an error occurs: the OnTask function will not be called } // control is returned to BREW environment after this code ended, // the Ontask function will be called by BREW environment in the next event loop } /// callback function called by BREW environment in the next event loop XALLBACK_IMPLEMENT_SFXTASK(MyClass, OnTask) { ... }
Constructor/Destructor |
---|
SFXTask( Void ) Constructor of the SFXTask class.
|
~SFXTask( Void ) Destructor of the SFXTask class.
|
Public Functions | |
---|---|
Void |
Cancel( Void ) Cancel the scheduled task.
|
static SFXTaskConstRef |
EmptyInstance( Void ) Get the empty task.
|
SFXCallback::CallbackSPP |
GetProcedure( Void ) Get the callback function set to this task.
|
VoidPtr |
GetReference( Void ) Get the data passed to the callback function set to this task.
|
Bool |
IsValid( Void ) Check whether or not the task is scheduled.
|
SFCError |
Schedule( Void ) Schedule the task.
|
Void |
Set(
SFXCallback::CallbackSPP spp
, VoidPtr reference
) Set information necessary to schedule the task.
|
[ public, explicit ] SFXTask(Void);
This constructor does nothing.
[ public ] ~SFXTask(Void);
This destructor cancels to schedule the task by calling the SFXTask::Cancel function internally.
[ public ] Void Cancel(Void);
This function cancels the scheduled task, i.e., the registered callback.
The task scheduled with the SFXTask::Schedule function will be canceled. If no task is scheduled, nothing will happen.
Tip | |
---|---|
When an application suspends, it is recommended to cancel the scheduled task with this function. |
Note | |
---|---|
This function is called in the SFXTask::~SFXTask destructor. |
Note | |
---|---|
Internally, this function calls the SFXCallback::Cancel function. |
[ public, static ] SFXTaskConstRef EmptyInstance(Void);
Empty SFXTask instance
This function gets the instance that represents an empty task.
[ public, const ] SFXCallback::CallbackSPP GetProcedure(Void);
Callback function set to this task.
This function gets the callback function set to this task with the SFXTask::Set function.
Note | |
---|---|
Internally, this function calls the SFXCallback::GetProcedure function. Concretely, the value of the pfnNotify member of the BREW API AEECallback structure internally contained by this task will be returned. |
[ public, const ] VoidPtr GetReference(Void);
Data passed to the callback function set to this task
This function gets the data passed to the callback function set to this task with the SFXTask::Set function.
Note | |
---|---|
Internally, this function calls the SFXCallback::GetReference function. Concretely, the value of the pNotifyData member of the BREW API AEECallback structure internally contained by this task will be returned. |
[ public, const ] Bool IsValid(Void);
This function whether or not the task is schedule with the SFXTask::Schedule function.
Note | |
---|---|
Internally, this function calls the SFXCallback::IsQueued function. |
[ public ] SFCError Schedule(Void);
This function schedules the task, i.e., registers the callback into the AEE shell.
If the task has already been scheduled, it will be canceled and scheduled again.
If this function is executed, the callback function set with the SFXTask::Set function will be called in the next event loop.
Note | |
---|---|
Internally, after the task is canceled with the SFXTask::Cancel function, then it will be scheduled again with the SFBShell::Resume function. |
Prerequisite | |
---|---|
Before this function is called, it is necessary to set the task with the SFXTask::Set function. |
SFXTask::Set | SFXTask::Cancel | SFXTask::IsValid | SFBShell | BREW API ISHELL_Resume
[ public ] Void Set( SFXCallback::CallbackSPP spp // callback function VoidPtr reference // data passed to the callback function );
This function sets information(callback function and data passed to it) necessary to schedule the task.
Internally, since the SFXTask::Cancel function is called first, the task that has been already scheduled before this function is called will be canceled.
Note | |
---|---|
After this function is executed, schedule the task with the SFXTask::Schedule function (register the callback). |
Note | |
---|---|
This function internally calls the SFXCallback::Set function to set the callback function and the data passed to it specified in the arguments to the pfnNotify member and the pNotifyData member of the BREW API AEECallback structure internally contained by this task. |
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |