~ubuntu-branches/ubuntu/utopic/glame/utopic

« back to all changes in this revision

Viewing changes to doc/glsignal.texi

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2002-04-09 17:14:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020409171412-jzpnov7mbz2w6zsr
Tags: upstream-0.6.2
ImportĀ upstreamĀ versionĀ 0.6.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
@comment $Id: glsignal.texi,v 1.5 2001/08/03 12:54:16 richi Exp $
 
2
 
 
3
@node GLAME Signal Interface, Function and Type Index, GLAME Database Interface, Top
 
4
@chapter GLAME Signal Interface
 
5
 
 
6
Generic signals via callbacks (@code{glsig_handler_t}), issuable from a
 
7
glsig_emitter. Signal masks are supported, as is a hierarchy of the
 
8
signal emitters.
 
9
 
 
10
WARNING! No explicit threading support is included, i.e. do your own
 
11
locking (you have to protect the emitter against concurrent addition and
 
12
removal of handlers and emit of signals). Also a handler will be invoked
 
13
in the thread context of the emitter, not in the one which added the
 
14
handler. If you want to emit signals from real signal handlers you have
 
15
to ensure yourself that your handlers are signal safe - also they should
 
16
be reentrant as parallel invocation from different threads is not
 
17
protected against.
 
18
 
 
19
Brief description of the available API follows: 
 
20
 
 
21
@deftp void {(glsig_callb_t)} (glsig_handler_t *, long, va_list)
 
22
  The type of the used callback functions through which signals
 
23
  are supposed to be handled.
 
24
@end deftp
 
25
 
 
26
@tindex glsig_emitter_t
 
27
@deftypefun {} INIT_GLSIG_EMITTER ( glsig_emitter_t *@var{emitter})
 
28
  Inits an emitter. No signal handlers are attached initially.
 
29
@end deftypefun
 
30
 
 
31
@tindex glsig_emitter_t
 
32
@tindex glsig_handler_t
 
33
@tindex glsig_callb_t
 
34
@deftypefun {glsig_handler_t *} glsig_add_handler ( glsig_emitter_t *@var{emitter}, long @var{sigmask}, glsig_callb_t *@var{cb}, void *@var{priv})
 
35
  Adds a signal handler to the emitter using the specified sigmask
 
36
  and the callback handler. The priv data is stored in the handlers
 
37
  ->priv field which you should access using @code{glsig_handler_private()}.
 
38
@end deftypefun
 
39
 
 
40
@tindex glsig_emitter_t
 
41
@tindex glsig_handler_t
 
42
@deftypefun {glsig_handler_t *} glsig_add_redirector ( glsig_emitter_t *@var{emitter}, long @var{sigmask}, glsig_emitter_t *@var{dest})
 
43
  Adds a redirector to the emitter. All signals raised from the emitter
 
44
  matching the specified signal mask will be raised again from the dest emitt
 
45
@end deftypefun
 
46
 
 
47
@tindex glsig_emitter_t
 
48
@deftypefun void glsig_emit ( glsig_emitter_t *@var{emitter}, int @var{sig}, ...)
 
49
  Emits the signal sig from the emitter and provides the varargs
 
50
  to the callbacks. Signals are emitted bottom to top in the hierarchy.
 
51
  It is safe to remove your signal handler during execution.
 
52
@end deftypefun
 
53
 
 
54
@tindex glsig_emitter_t
 
55
@deftypefun int glsig_copy_handlers ( glsig_emitter_t *@var{dest}, glsig_emitter_t *@var{source})
 
56
  Copies all handlers from one emitter to another - same "private"
 
57
  data, of course. Can return -1 on memory shortage. Redirectors are
 
58
  not copied.
 
59
@end deftypefun
 
60
 
 
61
@tindex glsig_emitter_t
 
62
@deftypefun int glsig_copy_redirectors ( glsig_emitter_t *@var{dest}, glsig_emitter_t *@var{source})
 
63
  Copies all redirectors from one emitter to another - same "private"
 
64
  data, of course. Can return -1 on memory shortage. Normal handlers
 
65
  are not copied.
 
66
@end deftypefun
 
67
 
 
68
@tindex glsig_handler_t
 
69
@deftypefun void glsig_delete_handler ( glsig_handler_t *@var{handler})
 
70
  Removes and destroyes the specified handler from its emitter.
 
71
@end deftypefun
 
72
 
 
73
@tindex glsig_emitter_t
 
74
@deftypefun void glsig_delete_all ( glsig_emitter_t *@var{emitter})
 
75
  Removes and destroyes all signal handlers from the specified emitter.
 
76
  Use with care.
 
77
@end deftypefun
 
78
 
 
79
@tindex glsig_handler_t
 
80
@deftypefun void glsig_handler_exec ( glsig_handler_t *@var{h}, int @var{sig}, ...)
 
81
  Executes the specified signal handler. Usually you dont want to use
 
82
  this, instead use @code{glsig_emit()}.
 
83
@end deftypefun
 
84
 
 
85
 
 
86
Inside signal handlers you may access the passed parameters (which you
 
87
should know by type and count) with the following macros.
 
88
 
 
89
@deftypefun void GLSIGH_GETARGS1 ( va_list @var{va}, type1 @var{var1})
 
90
@deftypefunx void GLSIGH_GETARGS2 ( va_list @var{va}, type1 @var{var1}, type2 @var{var2})
 
91
@deftypefunx void GLSIGH_GETARGS3 ( va_list @var{va}, type1 @var{var1}, type2 @var{var2}, type3 @var{var3})
 
92
@deftypefunx void GLSIGH_GETARGS4 ( va_list @var{va}, type1 @var{var1}, type2 @var{var2}, type3 @var{var3}, type4 @var{var4})
 
93
These macros initialize the provided variables with the passed parameters.
 
94
Beware that passing types with @code{sizeof(type)} not equal to
 
95
@code{sizeof(void *)} is not safe on compilers other than gcc.
 
96
@end deftypefun
 
97