summaryrefslogtreecommitdiff
path: root/toxav/event.h
blob: f9e675430ac5f4fefc242edc5a1551a8247f242f (plain)
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
/**  event.h
 *
 *   Copyright (C) 2013 Tox project All Rights Reserved.
 *
 *   This file is part of Tox.
 *
 *   Tox is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   Tox is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with Tox. If not, see <http://www.gnu.org/licenses/>.
 *
 *
 *   Report bugs/suggestions at #tox-dev @ freenode.net:6667
 */


#ifndef __TOXEVENT
#define __TOXEVENT


/**
 * - Events are, in fact, ran in their own threads upon execution.
 * - Event handler is initialized at the start, before the main() function
 *      and terminated after it's execution.
 * - Timers are checked for timeout every ~10000 ns.
 * - Timers can be canceled or ran immediately via
 *      timer_release() or timer_now() functions.
 * - Timeout is measured in milliseconds.
 *
 * NOTE: timer_reset () and timer_now() are not tested nor usable atm
 *
 */
extern struct _Event {
    int (*rise) (void *( func ) ( void *), void *arg);
    int (*timer_reset ) ( int id, unsigned timeout );
    int (*timer_alloc) (void *( func ) ( void *), void *arg, unsigned timeout);
    int (*timer_release) (int id);
    int (*timer_now) ( int id );
} event;

#endif /* _MSI__EVENT_H_ */