diff options
author | 2017-04-03 17:22:39 +0200 | |
---|---|---|
committer | 2017-04-03 17:22:39 +0200 | |
commit | e3a5ff981c25dcb609fe8cc5396a50b81138ee63 (patch) | |
tree | 7dc29eb4b5ea7d87826eee57f4fe92cf4de479de /src/tests | |
parent | 7087ad1b81b55fb2c1c14e7d9cbb49c0bf75e28e (diff) |
Rework the jobs
Enforce starting jobs with acquiring the
calling thread.
Removes invoke methods in favour of
enter/leave synchronisation.
Change-Id: I7086f7f53b919b43ddafd2355316abc0d3516f49
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/test-thread.c | 21 | ||||
-rwxr-xr-x | src/tests/test-thread.sh | 2 |
2 files changed, 15 insertions, 8 deletions
diff --git a/src/tests/test-thread.c b/src/tests/test-thread.c index 30e27a2e..d3ce08c1 100644 --- a/src/tests/test-thread.c +++ b/src/tests/test-thread.c @@ -81,7 +81,7 @@ void terminate(int signum) exit(0); } -int main() +void start() { int i; struct foo *foo; @@ -89,7 +89,6 @@ int main() struct timespec ts; req.itf = &itf; - jobs_init(4, 0, 20000); for (i = 0 ; i < 10000 ; i++) { req.closure = foo = malloc(sizeof *foo); foo->value = i; @@ -97,18 +96,26 @@ int main() afb_thread_req_call(req, process, 5, (&ts) + (i % 7)); unref(foo); if (i == 5000) -#if 0 - jobs_invoke0(0, terminate); -#else jobs_queue0(NULL, 0, terminate); -#endif ts.tv_sec = 0; ts.tv_nsec = 1000000; // nanosleep(&ts, NULL); } - return -jobs_add_me(); } +int main() +{ + int i; + struct foo *foo; + struct afb_req req; + struct timespec ts; + + req.itf = &itf; + jobs_start(4, 0, 20000, start); + return 1; +} + + diff --git a/src/tests/test-thread.sh b/src/tests/test-thread.sh index a9e2ee3b..a7bb45af 100755 --- a/src/tests/test-thread.sh +++ b/src/tests/test-thread.sh @@ -1,4 +1,4 @@ #!/bin/sh -cc test-thread.c ../afb-thread.c ../verbose.c ../sig-monitor.c ../jobs.c -o test-thread -lrt -lpthread -lsystemd I../../include -g +cc test-thread.c ../afb-thread.c ../verbose.c ../sig-monitor.c ../jobs.c -o test-thread -lrt -lpthread -lsystemd -I../../include -g ./test-thread |