Lely core libraries 2.3.4
exec.h File Reference

This header file is part of the event library; it contains the abstract task executor interface. More...

#include <lely/ev/ev.h>
#include <stddef.h>
Include dependency graph for exec.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ev_exec_vtbl
 

Functions

void ev_exec_on_task_init (ev_exec_t *exec)
 Indicates to the specified executor that a task will be submitted for execution in the future. More...
 
void ev_exec_on_task_fini (ev_exec_t *exec)
 Undoes the effect of a previous call to ev_exec_on_task_init().
 
int ev_exec_dispatch (ev_exec_t *exec, struct ev_task *task)
 Submits *task to *exec for execution. More...
 
void ev_exec_post (ev_exec_t *exec, struct ev_task *task)
 Submits *task to *exec for execution. More...
 
void ev_exec_defer (ev_exec_t *exec, struct ev_task *task)
 Submits *task to *exec for execution. More...
 
size_t ev_exec_abort (ev_exec_t *exec, struct ev_task *task)
 Aborts the specified task submitted to *exec, if it has not yet begun executing, or all pending tasks if task is NULL. More...
 
void ev_exec_run (ev_exec_t *exec, struct ev_task *task)
 Invokes the task function in *task as if the task is being executed by *exec. More...
 

Detailed Description

This header file is part of the event library; it contains the abstract task executor interface.

Author
J. S. Seldenthuis jseld.nosp@m.enth.nosp@m.uis@l.nosp@m.ely..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file exec.h.

Function Documentation

◆ ev_exec_on_task_init()

void ev_exec_on_task_init ( ev_exec_t exec)
inline

Indicates to the specified executor that a task will be submitted for execution in the future.

This is typically used to prevent an event loop from terminating early.

Definition at line 106 of file exec.h.

◆ ev_exec_dispatch()

int ev_exec_dispatch ( ev_exec_t exec,
struct ev_task task 
)
inline

Submits *task to *exec for execution.

The task function is invoked at most once. The executor MAY block pending the completion of the task. This typically happens when this function is invoked from the execution context of *exec (i.e., by a task currently being executed).

Returns
1 if this function blocked and the task has completed, and 0 if not.
See also
ev_exec_post(), ev_exec_defer()

Definition at line 118 of file exec.h.

◆ ev_exec_post()

void ev_exec_post ( ev_exec_t exec,
struct ev_task task 
)
inline

Submits *task to *exec for execution.

The task function is invoked at most once. The executor SHALL NOT block pending the completion of the task, but MAY begin executing the task before this function returns.

See also
ev_exec_dispatch(), ev_exec_defer()

Definition at line 124 of file exec.h.

◆ ev_exec_defer()

void ev_exec_defer ( ev_exec_t exec,
struct ev_task task 
)
inline

Submits *task to *exec for execution.

The task function is invoked at most once. The executor SHALL NOT block pending the completion of the task, and, if invoked from a running task, SHALL NOT begin executing the task before the current task completes. This function is typically used to indicate that* *task is a continuation of the current call context.

See also
ev_exec_dispatch(), ev_exec_post()

Definition at line 130 of file exec.h.

◆ ev_exec_abort()

size_t ev_exec_abort ( ev_exec_t exec,
struct ev_task task 
)
inline

Aborts the specified task submitted to *exec, if it has not yet begun executing, or all pending tasks if task is NULL.

Returns
the number of aborted tasks.

Definition at line 136 of file exec.h.

◆ ev_exec_run()

void ev_exec_run ( ev_exec_t exec,
struct ev_task task 
)
inline

Invokes the task function in *task as if the task is being executed by *exec.

This function typically sets up an execution context in which ev_exec_dispatch() and ev_exec_defer() behave differently than if the task function is invoked directly.

Definition at line 142 of file exec.h.