File: observer.c

package info (click to toggle)
xwax 1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 576 kB
  • sloc: ansic: 6,687; sh: 170; makefile: 142
file content (28 lines) | stat: -rw-r--r-- 449 bytes parent folder | download | duplicates (4)
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
#include <stdio.h>

#include "observer.h"

void callback(struct observer *t, void *x)
{
    fprintf(stderr, "observer %p fired with argument %p\n", t, x);
}

int main(int argc, char *argv[])
{
    struct event s;
    struct observer t, u;

    event_init(&s);

    watch(&t, &s, callback);
    watch(&u, &s, callback);

    fire(&s, (void*)0xbeef);
    ignore(&u);
    fire(&s, (void*)0xcafe);
    ignore(&t);

    event_clear(&s);

    return 0;
}