A Process constructed from a functor with signature EGenericProcessResult(uint64_t,Process)*.
More...
#include <GenericProcess.h>
|
|
typedef std::function< EGenericProcessResult(uint64_t, Process *)> | GenericCallback |
| |
| enum | EProcessState : uint8_t {
PREPARED
, INITIATED
, ASLEEP
, PREPARED_TO_DIE
,
TRYING_TO_KILL
, KILLING_WAITING_FOR_SCHEDULED
, DEAD
} |
| |
| enum class | ESwitchResult { ESWITCH_OK
, ESWITCH_WAKEUP
, ESWITCH_ERROR
, ESWITCH_KILL
} |
| | Reason why the process returns from context switch. More...
|
| |
|
| void | onInit (uint64_t msegs) override |
| |
| bool | onKill () override |
| |
| void | onUpdate (uint64_t msegs) override |
| |
|
virtual void | onPause () |
| | Called when a process is paused.
|
| |
|
virtual void | onWakeUp () |
| | Called when process is woken up.
|
| |
| virtual void | killDone () |
| |
A Process constructed from a functor with signature EGenericProcessResult(uint64_t,Process)*.
This process it's executed until given functor returns EGenericProcessResult::KILL.
◆ EProcessState
| Enumerator |
|---|
| PREPARED | Process created but not executed.
|
| INITIATED | executing process normally
|
| ASLEEP | sleeping. Waiting for a wakeup
|
| PREPARED_TO_DIE | it's going to die, but process manager doesn't discard it yet
|
| TRYING_TO_KILL | sending kill signal but no accepted yet
|
| KILLING_WAITING_FOR_SCHEDULED | switched and no shceduled yet
|
| DEAD | process is out of process manager
|
◆ ESwitchResult
Reason why the process returns from context switch.
| Enumerator |
|---|
| ESWITCH_OK | return from context switch was ok
|
| ESWITCH_WAKEUP | return from context switch was because a wakeup
|
| ESWITCH_ERROR | switch couldn't be done
|
| ESWITCH_KILL | return from context switch because a kill
|
◆ GenericProcess()
| mel::tasking::GenericProcess::GenericProcess |
( |
| ) |
|
◆ getDead()
| bool mel::tasking::Process::getDead |
( |
| ) |
const |
|
inlineinherited |
◆ getElapsedTime()
| unsigned int mel::tasking::Process::getElapsedTime |
( |
| ) |
const |
|
inherited |
returns time elapsed during this iteration
◆ getLastUpdateTime()
| uint64_t mel::tasking::Process::getLastUpdateTime |
( |
| ) |
const |
|
inlineinherited |
- Returns
- time when task was executed in last iteration, when onUpdate is called:
- Note
- context switches or waits inside code doesn't modify update time.
◆ getPeriod()
| unsigned int mel::tasking::Process::getPeriod |
( |
| ) |
const |
|
inlineinherited |
get period (milliseconds)
check if process is going to die
◆ kill()
| void mel::tasking::Process::kill |
( |
bool |
force = false | ) |
|
|
inherited |
Mark this process to be eliminated by the process manager.
Internally, kill calls virtual function Process::onKill, which returns true if kill can be acomplished or not. In case of true, then process is put in PREPARED_TO_DIE state, so the scheduler can remove it. In case of false, process is put in a TRYING_TO_KILL state so scheduler will continue to trying to kill it in next iterations. You can know if a process is die checking getDead
- Parameters
-
| [in] | force | if true, then killing is without regarding previous explained process, so Process go inmediately to PREPARED_TO_DIE |
◆ killDone()
| virtual void mel::tasking::Process::killDone |
( |
| ) |
|
|
inlineprotectedvirtualinherited |
called when kill is definitively done
◆ onInit()
| void mel::tasking::GenericProcess::onInit |
( |
uint64_t |
msecs | ) |
|
|
overrideprotectedvirtual |
◆ onKill()
| bool mel::tasking::GenericProcess::onKill |
( |
| ) |
|
|
overrideprotectedvirtual |
◆ onUpdate()
| void mel::tasking::GenericProcess::onUpdate |
( |
uint64_t |
msegs | ) |
|
|
overrideprotectedvirtual |
◆ setPeriod()
| void mel::tasking::Process::setPeriod |
( |
unsigned int |
value | ) |
|
|
inlineinherited |
Set the period for this process.
- Parameters
-
| value | the new period (in msecs) |
◆ setProcessCallback()
template<class F >
| void mel::tasking::GenericProcess::setProcessCallback |
( |
F && |
functor | ) |
|
Set callable to be executed on process update.
- Parameters
-
| [in] | functor | A functor with signature EGenericProcessResult(uint64_t,Process*) |
◆ sleep()
pause current process. To reactivate you must use wakeUp
- Returns
- true if process received kill signal
- See also
- switchProcess for comments
◆ sleepAndDo()
Sleep current process and execute given callable. To reactivate to you must use wakeUp.
- Parameters
-
| [in] | postSleep | functor (signature void(void) ) to execute just in the moment when Process go to sleep |
- Returns
- resulting state of these operation
- See also
- sleep
◆ switchProcess()
| static ESwitchResult mel::tasking::Process::switchProcess |
( |
bool |
continueInmediately | ) |
|
|
staticinherited |
Evict current process and will continue executing from the same point the next time is scheduled.
this function is a static one because, in the same way threads work, is the currently executing process which can be evicted in any point of the execution call stack.
- Parameters
-
| continueInmediately | if true, the process will continue executing in the next shceduler cycle, so without respecting the period. |
◆ wait()
| static ESwitchResult mel::tasking::Process::wait |
( |
unsigned int |
msegs | ) |
|
|
staticinherited |
- Returns
- true if process received kill signal
- See also
- switchProcess for comments
◆ waitAndDo()
Wait for a given time and execute given callable.
- Parameters
-
| [in] | postWait | functor (signature <void,void>) to execute just in the moment when Process go to sleep |
- Returns
- resulting state of the operation
- See also
- sleep
The documentation for this class was generated from the following file: