Class Efl.Loop
The Efl Main Loop The Efl main loop provides a clean and tiny event loop library with many modules to do lots of convenient things for a programmer, saving time and effort. It's lean and designed to work on anything from embedded systems all the way up to large and powerful multi-cpu workstations. The main loop has a number of primitives you can use. It serializes these and allows for greater responsiveness without the need for threads (or any other concurrency). However you can provide these if you need to. (Since EFL 1.22)
Syntax
public abstract class Loop : Task, IWrapper, IDisposable
Constructors
Loop(EoWrapper.ConstructingHandle)
Subclasses should override this constructor if they are expected to be instantiated from native code. Do not call this constructor directly.
Declaration
protected Loop(EoWrapper.ConstructingHandle ch)
Parameters
Type | Name | Description |
---|---|---|
Efl.Eo.EoWrapper.ConstructingHandle | ch | Tag struct storing the native handle of the object being constructed. |
Loop(Object)
Initializes a new instance of the Efl.Loop class.
Declaration
public Loop(Object parent = null)
Parameters
Type | Name | Description |
---|---|---|
Efl.Object | parent | Parent instance. |
Loop(IntPtr, Object)
Initializes a new instance of the Efl.Loop class. Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.
Declaration
protected Loop(IntPtr baseKlass, Object parent)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | baseKlass | The pointer to the base native Eo class. |
Efl.Object | parent | The Efl.Object parent of this instance. |
Properties
Throttle
Slow down the loop execution by forcing sleep for a small period of time every time the loop iterates/loops. (Since EFL 1.22)
Declaration
public double Throttle { get; set; }
Property Value
Type | Description |
---|---|
System.Double | Time to sleep for each "loop iteration" |
Time
Retrieves the time at which the last loop stopped waiting for timeouts or events. (Since EFL 1.22)
Declaration
public double Time { get; protected set; }
Property Value
Type | Description |
---|---|
System.Double | Time in seconds |
Methods
Begin()
Runs the application main loop. (Since EFL 1.22)
Declaration
public virtual Value Begin()
Returns
Type | Description |
---|---|
Eina.Value | Value set by quit() |
GetThrottle()
Slow down the loop execution by forcing sleep for a small period of time every time the loop iterates/loops. (Since EFL 1.22)
Declaration
public virtual double GetThrottle()
Returns
Type | Description |
---|---|
System.Double | Time to sleep for each "loop iteration" |
GetTime()
This gets the time that the main loop ceased waiting for timouts and/or events to come in or for signals or any other interrupt source. This should be considered a reference point for all time based activity that should calculate its timepoint from the return of ecore_loop_time_get(). Note that this time is meant to be used as relative to other times obtained on this run. If you need absolute time references, use a unix timestamp instead. (Since EFL 1.22)
Declaration
public virtual double GetTime()
Returns
Type | Description |
---|---|
System.Double | Time in seconds |
Idle()
A future promise that will be resolved from a clean main loop context as soon as the main loop is idle. This is a low priority version of Efl.Loop.Job() (Since EFL 1.22)
Declaration
public virtual Future Idle()
Returns
Type | Description |
---|---|
Eina.Future | The future handle. |
IdleAsync(CancellationToken)
Async wrapper for Efl.Loop.Idle().
Declaration
public Task<Value> IdleAsync(CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | token | Token to notify the async operation of external request to cancel. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Eina.Value> | An async task wrapping the result of the operation. |
Iterate()
Runs a single iteration of the main loop to process everything on the queue. (Since EFL 1.22)
Declaration
public virtual void Iterate()
IterateMayBlock(Int32)
Runs a single iteration of the main loop to process everything on the queue with block/non-blocking status. (Since EFL 1.22)
Declaration
public virtual int IterateMayBlock(int may_block)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | may_block | A flag if the main loop has a possibility of blocking. |
Returns
Type | Description |
---|---|
System.Int32 | Return from single iteration run |
Job()
A future promise that will be resolved from a clean main loop context as soon as possible. This has higher priority, for low priority use Efl.Loop.Idle() (Since EFL 1.22)
Declaration
public virtual Future Job()
Returns
Type | Description |
---|---|
Eina.Future | The future handle. |
JobAsync(CancellationToken)
Async wrapper for Efl.Loop.Job().
Declaration
public Task<Value> JobAsync(CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | token | Token to notify the async operation of external request to cancel. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Eina.Value> | An async task wrapping the result of the operation. |
OnArgumentsEvent(LoopArgumentsEventArgs)
Method to raise event ArgumentsEvent.
Declaration
public void OnArgumentsEvent(LoopArgumentsEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
Efl.LoopArgumentsEventArgs | e | Event to raise. |
OnIdleEnterEvent(EventArgs)
Method to raise event IdleEnterEvent.
Declaration
public void OnIdleEnterEvent(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Event to raise. |
OnIdleEvent(EventArgs)
Method to raise event IdleEvent.
Declaration
public void OnIdleEvent(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Event to raise. |
OnIdleExitEvent(EventArgs)
Method to raise event IdleExitEvent.
Declaration
public void OnIdleExitEvent(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Event to raise. |
OnPollHighEvent(EventArgs)
Method to raise event PollHighEvent.
Declaration
public void OnPollHighEvent(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Event to raise. |
OnPollLowEvent(EventArgs)
Method to raise event PollLowEvent.
Declaration
public void OnPollLowEvent(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Event to raise. |
OnPollMediumEvent(EventArgs)
Method to raise event PollMediumEvent.
Declaration
public void OnPollMediumEvent(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Event to raise. |
OnQuitEvent(EventArgs)
Method to raise event QuitEvent.
Declaration
public void OnQuitEvent(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Event to raise. |
Quit(Value)
Quits the main loop once all the events currently on the queue have been processed. (Since EFL 1.22)
Declaration
public virtual void Quit(Value exit_code)
Parameters
Type | Name | Description |
---|---|---|
Eina.Value | exit_code | Returned value by begin() |
SetThrottle(Double)
Slow down the loop execution by forcing sleep for a small period of time every time the loop iterates/loops. (Since EFL 1.22)
Declaration
public virtual void SetThrottle(double amount)
Parameters
Type | Name | Description |
---|---|---|
System.Double | amount | Time to sleep for each "loop iteration" |
SetTime(Double)
You should never need/call this, unless you are implementing a custom tick source for an animator. Note: The time point must match whatever zero time you get from ecore_time_get() and Efl.Loop.GetTime() (same 0 point). What this point is is undefined, so unless your source uses the same 0 time, then you may have to adjust and do some guessing. (Since EFL 1.22)
Declaration
protected virtual void SetTime(double timepoint)
Parameters
Type | Name | Description |
---|---|---|
System.Double | timepoint | Time in seconds |
Timeout(Double)
A future promise that will be resolved from a clean main loop context after time
seconds.
(Since EFL 1.22)
Declaration
public virtual Future Timeout(double time)
Parameters
Type | Name | Description |
---|---|---|
System.Double | time | The time from now in second that the main loop will wait before triggering it. |
Returns
Type | Description |
---|---|
Eina.Future | The future handle. |
TimeoutAsync(Double, CancellationToken)
Async wrapper for Efl.Loop.Timeout(System.Double).
Declaration
public Task<Value> TimeoutAsync(double time, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Double | time | The time from now in second that the main loop will wait before triggering it. |
System.Threading.CancellationToken | token | Token to notify the async operation of external request to cancel. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Eina.Value> | An async task wrapping the result of the operation. |
Events
ArgumentsEvent
Event happens when args are provided to the loop by args_add(). (Since EFL 1.22)
Declaration
public event EventHandler<LoopArgumentsEventArgs> ArgumentsEvent
Event Type
Type | Description |
---|---|
System.EventHandler<Efl.LoopArgumentsEventArgs> |
IdleEnterEvent
Event occurs once the main loop enters the idle state. (Since EFL 1.22)
Declaration
public event EventHandler IdleEnterEvent
Event Type
Type | Description |
---|---|
System.EventHandler |
IdleEvent
Event occurs once the main loop is idle. If you keep listening on this event it may increase the burden on your CPU. (Since EFL 1.22)
Declaration
public event EventHandler IdleEvent
Event Type
Type | Description |
---|---|
System.EventHandler |
IdleExitEvent
Event occurs once the main loop exits the idle state. (Since EFL 1.22)
Declaration
public event EventHandler IdleExitEvent
Event Type
Type | Description |
---|---|
System.EventHandler |
PollHighEvent
Event occurs multiple times per second. The exact tick is undefined and can be adjusted system-wide. (Since EFL 1.22)
Declaration
public event EventHandler PollHighEvent
Event Type
Type | Description |
---|---|
System.EventHandler |
PollLowEvent
Event occurs multiple times every 15 minutes. The exact tick is undefined and can be adjusted system-wide. (Since EFL 1.22)
Declaration
public event EventHandler PollLowEvent
Event Type
Type | Description |
---|---|
System.EventHandler |
PollMediumEvent
Event occurs multiple times per minute. The exact tick is undefined and can be adjusted system-wide. (Since EFL 1.22)
Declaration
public event EventHandler PollMediumEvent
Event Type
Type | Description |
---|---|
System.EventHandler |
QuitEvent
Event occurs when the loop was requested to quit externally e.g. by a ctrl+c signal or a request from a parent loop/thread to have the child exit. (Since EFL 1.22)
Declaration
public event EventHandler QuitEvent
Event Type
Type | Description |
---|---|
System.EventHandler |