summaryrefslogtreecommitdiff
path: root/src/lib/ecore/efl_loop.eo
blob: e8cadb5fdeef31311133006a9756ae40f4097000 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
struct Efl.Loop_Arguments {
   [[EFL loop arguments data structure]]
   argv: const(array<const(stringshare)>); [[Array with loop arguments]]
   initialization: bool; [[Set to $true when the program should initialize its internal state. This happen once per process instance.]]
}

abstract @beta Efl.Loop extends Efl.Task
{
   [[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.
   ]]
   methods {
      iterate {
         [[Runs a single iteration of the main loop to process everything on the
         queue.]]
      }
      iterate_may_block {
         [[Runs a single iteration of the main loop to process everything on the
           queue with block/non-blocking status.]]
         return: int; [[Return from single iteration run]]
         params {
            may_block: int; [[A flag if the main loop has a possibility of blocking.]]
         }
      }
      begin {
         [[Runs the application main loop.]]
         return: any_value_ptr; [[Value set by quit()]]
      }
      quit {
         [[Quits the main loop once all the events currently on the queue have
         been processed.]]
         params {
            @in exit_code: any_value; [[Returned value by begin()]]
         }
      }
      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
           @.idle
         ]]
         return: future<void> @owned; [[The future handle.]]
      }
      @property throttle {
         [[Slow down the loop execution by forcing sleep for a small
           period of time every time the loop iterates/loops.]]
         set {}
         get {}
         values {
           amount : double; [[Time to sleep for each "loop iteration"]]
         }
      }
      @property time {
         [[Retrieves the time at which the last loop stopped waiting for timeouts or events.]]
         set @protected {
           [[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 @.time.get() (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.
           ]]
         }
         get {
           [[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.
            ]]
         }
         values {
           timepoint: 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 @.job
         ]]
         return: future<void> @owned; [[The future handle.]]
      }
      timeout {
         [[A future promise that will be resolved from a clean main
           loop context after $time seconds.]]
         params {
            @in time: double; [[The time from now in second that the main loop will wait before triggering it.]]
         }
         return: future<void> @owned; [[The future handle.]]
      }
      register {
         [[Will register a manager of a specific class to be answered by eo.provider_find.]]
         params {
            @in klass: const(Efl.Class); [[The class provided by the registered provider.]]
            @in provider: const(Efl.Object); [[The provider for the newly registered class that has to provide that said Efl.Class.]]
         }
         return: bool; [[$true if successfully register, $false otherwise.]]
      }
      unregister {
         [[Will unregister a manager of a specific class that was previously registered and answered by eo.provider_find.]]
         params {
            @in klass: const(Efl.Class); [[The class provided by the provider to unregister for.]]
            @in provider: const(Efl.Object); [[The provider for the registered class to unregister.]]
         }
         return: bool; [[$true if successfully unregistered, $false otherwise.]]
      }
   }
   events {
      idle,enter @restart: void; [[Event occurs once the main loop enters the idle state.]]
      idle,exit @restart: void; [[Event occurs once the main loop exits the idle state.]]
      idle @restart: void; [[Event occurs once the main loop is idle. If you keep listening on this event it may increase the burden on your CPU.]]
      arguments: Efl.Loop_Arguments; [[Event happens when args are provided to the loop by args_add().]]
      poll,high: void; [[Event occurs multiple times per second. The exact tick is undefined and can be adjusted system wide.]]
      poll,medium: void; [[Event occurs multiple times per minute. The exact tick is undefined and can be adjusted system wide.]]
      poll,low: void; [[Event occurs multiple times every 15 minutes. The exact tick is undefined and can be adjusted system wide.]]
      quit: void; [[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.]]
   }
   implements {
      Efl.Object.constructor;
      Efl.Object.invalidate;
      Efl.Object.destructor;
      Efl.Object.provider_find;
      Efl.Task.run;
      Efl.Task.end;
   }
}