T-EMU  2
The Terma Emulator
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Events.h
Go to the documentation of this file.
1 //===-- temu-c/Events.h - Event Queue API -----------------------*- C++ -*-===//
2 //
3 // T-EMU: The Terma Emulator
4 // (c) Terma 2015
5 // Authors: Mattias Holm <maho (at) terma.com>
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef TEMU_EVENTS_H
10 #define TEMU_EVENTS_H
11 
12 #include <stdint.h>
13 #include "temu-c/Support/Objsys.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #define TEMU_EVENT_NS (1U << 0)
20 #define TEMU_EVENT_SYNC (1U << 8)
21 
22 typedef void (*temu_TimerCb)(void *Sender, void *Data);
23 
24 void* temu_allocateEventQueue(void);
25 void temu_disposeEventQueue(void *Queue);
26 
27 int64_t temu_triggerFirstTimer(void *Queue, uint32_t Flags);
28 int64_t temu_triggerCurrentTimers(void *Queue, int64_t Srt, uint32_t Flags);
29 
30 int64_t temu_nextTimer(void *Queue, uint32_t Flags);
31 
32 void temu_postEvent(void *Queue, temu_TimerCb callback,
33  void *Sender, void *Data, uint64_t Time, uint32_t Flags);
34 
35 void temu_stackEvent(void *Queue, temu_TimerCb callback,
36  void *Sender, void *Data, uint32_t Flags);
37 
38 /*
39  \brief Get the next time stamp for the given callback function.
40  */
41 int64_t temu_eventTime(void *Queue, temu_TimerCb callback,
42  void *Sender);
43 
44 void temu_descheduleEvent(void *Queue,
45  temu_TimerCb callback,
46  void *Sender);
47 
48 // Posting callback from other threads
49 typedef void (*temu_ThreadSafeCb)(void*);
50 void temu_postCallbackInQueue(void *Queue, temu_ThreadSafeCb Cb, void *Arg);
51 
52 typedef struct {
53  void (*stackPostEvent)(void *Obj, temu_TimerCb Ev, void *Sender, void *Data,
54  uint32_t Flags);
55 
56  void (*postDeltaEvent)(void *Obj, temu_TimerCb Ev, void *Sender, void *Data,
57  int64_t Cycles, uint32_t Flags);
58 
59  void (*postAbsoluteEvent)(void *Obj, temu_TimerCb Ev, void *Sender, void *Data,
60  int64_t Cycles, uint32_t Flags);
61  int64_t (*getEventDeltaTime)(void *Obj, temu_TimerCb Ev,
62  void *Sender);
63  int64_t (*getEventAbsoluteTime)(void *Obj, temu_TimerCb Ev,
64  void *Sender);
65  void (*descheduleEvent)(void *Obj, temu_TimerCb Ev, void *Sender,
66  uint32_t Flags);
67  void (*registerEvent)(void *Obj, const char *EvName,
68  void (*Ev)(void *, void *), uint32_t Flags);
69 
70  void (*postCallback)(void *Obj, temu_ThreadSafeCb Cb, void *Arg);
71 
73 
74 TEMU_IFACE_REFERENCE_TYPE(temu_Event);
75 
76 // Serialisation support
77 void temu_registerEvent(void *Queue, const char *Name,
78  temu_TimerCb Callback,
79  uint32_t Flags);
80 void temu_serialiseEvents(void *Obj, void *Ctxt);
81 void temu_deserialiseEvents(void *Obj, void *Ctxt);
82 
83 
84 #ifdef __cplusplus
85 }
86 #endif
87 
88 #endif /* ! TEMU_EVENTS_H */
void temu_serialiseEvents(void *Obj, void *Ctxt)
void(* temu_ThreadSafeCb)(void *)
Definition: Events.h:49
int64_t temu_triggerFirstTimer(void *Queue, uint32_t Flags)
void * temu_allocateEventQueue(void)
void temu_stackEvent(void *Queue, temu_TimerCb callback, void *Sender, void *Data, uint32_t Flags)
void temu_descheduleEvent(void *Queue, temu_TimerCb callback, void *Sender)
void(* temu_TimerCb)(void *Sender, void *Data)
Definition: Events.h:22
void temu_postEvent(void *Queue, temu_TimerCb callback, void *Sender, void *Data, uint64_t Time, uint32_t Flags)
void temu_postCallbackInQueue(void *Queue, temu_ThreadSafeCb Cb, void *Arg)
TEMU_IFACE_REFERENCE_TYPE(temu_Event)
void temu_registerEvent(void *Queue, const char *Name, temu_TimerCb Callback, uint32_t Flags)
void temu_deserialiseEvents(void *Obj, void *Ctxt)
void temu_disposeEventQueue(void *Queue)
int64_t temu_triggerCurrentTimers(void *Queue, int64_t Srt, uint32_t Flags)
int64_t temu_nextTimer(void *Queue, uint32_t Flags)
int64_t temu_eventTime(void *Queue, temu_TimerCb callback, void *Sender)