1iv_task(3)                ivykis programmer's manual                iv_task(3)
2
3
4

NAME

6       iv_task_register,  iv_task_unregister,  iv_task_registered  - deal with
7       ivykis tasks
8

SYNOPSIS

10       #include <iv.h>
11
12       struct iv_task {
13               void            *cookie;
14               void            (*handler)(void *);
15       };
16
17       void IV_TASK_INIT(struct iv_task *task);
18       void iv_task_register(struct iv_task *task);
19       void iv_task_unregister(struct iv_task *task);
20       int iv_task_registered(const struct iv_task *task);
21

DESCRIPTION

23       The functions iv_task_register and iv_task_unregister register, respec‐
24       tively  unregister, a task with the current thread's ivykis event loop.
25       iv_task_registered on a task returns true if  that  task  is  currently
26       registered with ivykis.
27
28       A  task is like a timer, but with an immediate timeout.  When a task is
29       registered, unless it is unregistered again first, the  callback  func‐
30       tion  specified  by  ->handler  is guaranteed to be called once, in the
31       thread that the task was registered in, some time after control returns
32       to  the  ivykis main loop but before ivykis will sleep for more events,
33       with ->cookie as its first and sole argument.  When this  happens,  the
34       task is transparently unregistered.
35
36       Tasks are mainly used for scheduling code for execution where it is not
37       appropriate to directly run that code in the calling context (for exam‐
38       ple,  because  the  current context might be run as a callback function
39       where the caller expects certain conditions to remain  invariant  after
40       the callback completes).
41
42       The application is allowed to change the ->cookie and ->handler members
43       at any time.
44
45       A given struct iv_task can only be registered in one thread at a  time,
46       and  a  task  can only be unregistered in the thread that it was regis‐
47       tered from.
48
49       There is no limit on the number of tasks registered at once.
50
51       See iv_examples(3) for programming examples.
52

SEE ALSO

54       ivykis(3), iv_examples(3)
55
56
57
58ivykis                            2010-08-15                        iv_task(3)
Impressum