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 ABORT T%d %s\n", foo->value, (int)syscall(SYS_gettid), 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);
73 void terminate(int signum)
75 printf("---------------- TERMINATE T%d (%d)\n", (int)syscall(SYS_gettid), signum);
79 jobs_invoke0(0, jobs_terminate);
92 for (i = 0 ; i < 10000 ; i++) {
93 req.closure = foo = malloc(sizeof *foo);
96 afb_thread_req_call(req, process, 5, (&ts) + (i % 7));
99 jobs_queue0(NULL, 0, terminate);
101 ts.tv_nsec = 1000000;
102 // nanosleep(&ts, NULL);
116 jobs_start(4, 0, 20000, start);