6 #include <sys/syscall.h>
8 #include <afb/afb-req-itf.h>
9 #include "../afb-thread.h"
17 void addref(void *closure)
19 struct foo *foo = closure;
23 void unref(void *closure)
25 struct foo *foo = closure;
26 if(!--foo->refcount) {
27 printf("%06d FREE\n", foo->value);
32 void fail(void *closure, const char *status, const char *info)
34 struct foo *foo = closure;
35 printf("%06d ERROR %s\n", foo->value, status);
38 struct afb_req_itf itf = {
54 .session_close = NULL,
55 .session_set_LOA = NULL,
63 void process(struct afb_req req)
66 struct foo *foo = req.closure;
67 printf("%06d PROCESS T%d\n", foo->value, (int)syscall(SYS_gettid));
69 ts.tv_nsec = foo->value * 1000;
70 // nanosleep(&ts, NULL);
81 jobs_init(4, 0, 20000);
82 for (i = 0 ; i < 10000 ; i++) {
83 req.closure = foo = malloc(sizeof *foo);
86 afb_thread_req_call(req, process, 5, (&ts) + (i % 7));
90 // nanosleep(&ts, NULL);