Code Review
/
src
/
app-framework-binder.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Update packaging
[src/app-framework-binder.git]
/
src
/
tests
/
test-thread.c
diff --git
a/src/tests/test-thread.c
b/src/tests/test-thread.c
index
cc676bd
..
d3ce08c
100644
(file)
--- a/
src/tests/test-thread.c
+++ b/
src/tests/test-thread.c
@@
-7,6
+7,7
@@
#include <afb/afb-req-itf.h>
#include "../afb-thread.h"
#include <afb/afb-req-itf.h>
#include "../afb-thread.h"
+#include "../jobs.h"
struct foo {
int value;
struct foo {
int value;
@@
-23,7
+24,7
@@
void unref(void *closure)
{
struct foo *foo = closure;
if(!--foo->refcount) {
{
struct foo *foo = closure;
if(!--foo->refcount) {
- printf("%06d FREE\n", foo->value);
+ /* printf("%06d FREE\n", foo->value); */
free(foo);
}
}
free(foo);
}
}
@@
-31,7
+32,7
@@
void unref(void *closure)
void fail(void *closure, const char *status, const char *info)
{
struct foo *foo = closure;
void fail(void *closure, const char *status, const char *info)
{
struct foo *foo = closure;
- printf("%06d
ERROR %s\n", foo->value
, status);
+ printf("%06d
ABORT T%d %s\n", foo->value, (int)syscall(SYS_gettid)
, status);
}
struct afb_req_itf itf = {
}
struct afb_req_itf itf = {
@@
-69,7
+70,18
@@
void process(struct afb_req req)
// nanosleep(&ts, NULL);
}
// nanosleep(&ts, NULL);
}
-int main()
+void terminate(int signum)
+{
+ printf("---------------- TERMINATE T%d (%d)\n", (int)syscall(SYS_gettid), signum);
+#if 1
+ jobs_terminate();
+#else
+ jobs_invoke0(0, jobs_terminate);
+#endif
+ exit(0);
+}
+
+void start()
{
int i;
struct foo *foo;
{
int i;
struct foo *foo;
@@
-77,23
+89,33
@@
int main()
struct timespec ts;
req.itf = &itf;
struct timespec ts;
req.itf = &itf;
- afb_thread_init(4, 1);
for (i = 0 ; i < 10000 ; i++) {
req.closure = foo = malloc(sizeof *foo);
foo->value = i;
foo->refcount = 1;
for (i = 0 ; i < 10000 ; i++) {
req.closure = foo = malloc(sizeof *foo);
foo->value = i;
foo->refcount = 1;
- afb_thread_
call(req, process, 5, (&ts) + (i % 4
));
+ afb_thread_
req_call(req, process, 5, (&ts) + (i % 7
));
unref(foo);
unref(foo);
+ if (i == 5000)
+ jobs_queue0(NULL, 0, terminate);
ts.tv_sec = 0;
ts.tv_nsec = 1000000;
// nanosleep(&ts, NULL);
}
ts.tv_sec = 0;
ts.tv_nsec = 1000000;
// nanosleep(&ts, NULL);
}
- ts.tv_sec = 1;
- ts.tv_nsec = 0;
- nanosleep(&ts, NULL);
- afb_thread_terminate();
}
}
+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;
+}
+
+