summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-01-31 23:49:25 +0000
committerDavid Robillard <d@drobilla.net>2012-01-31 23:49:25 +0000
commit5b3bde6f967940fb22f7160b3c9127a465a58f35 (patch)
tree8fd1c2229d1f25b55562e3958845d1868f73cb16 /test
parent73dee9781a50586129c944cf5e71879b1c970def (diff)
downloadzix-5b3bde6f967940fb22f7160b3c9127a465a58f35.tar.gz
zix-5b3bde6f967940fb22f7160b3c9127a465a58f35.tar.bz2
zix-5b3bde6f967940fb22f7160b3c9127a465a58f35.zip
Add thread abstraction.
git-svn-id: http://svn.drobilla.net/zix/trunk@53 df6676b4-ccc9-40e5-b5d6-7c4628a128e3
Diffstat (limited to 'test')
-rw-r--r--test/ring_test.c14
-rw-r--r--test/sem_test.c14
2 files changed, 14 insertions, 14 deletions
diff --git a/test/ring_test.c b/test/ring_test.c
index 658f6af..b7d181c 100644
--- a/test/ring_test.c
+++ b/test/ring_test.c
@@ -15,7 +15,6 @@
*/
#include <limits.h>
-#include <pthread.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
@@ -23,6 +22,7 @@
#include <string.h>
#include "zix/ring.h"
+#include "zix/thread.h"
#define MSG_SIZE 20
@@ -141,18 +141,18 @@ main(int argc, char** argv)
zix_ring_mlock(ring);
- pthread_t reader_thread;
- if (pthread_create(&reader_thread, NULL, reader, NULL)) {
+ ZixThread reader_thread;
+ if (zix_thread_create(&reader_thread, MSG_SIZE * 4, reader, NULL)) {
return failure("Failed to create reader thread\n");
}
- pthread_t writer_thread;
- if (pthread_create(&writer_thread, NULL, writer, NULL)) {
+ ZixThread writer_thread;
+ if (zix_thread_create(&writer_thread, MSG_SIZE * 4, writer, NULL)) {
return failure("Failed to create writer thread\n");
}
- pthread_join(reader_thread, NULL);
- pthread_join(writer_thread, NULL);
+ zix_thread_join(reader_thread, NULL);
+ zix_thread_join(writer_thread, NULL);
if (read_error) {
return failure("Read error\n");
diff --git a/test/sem_test.c b/test/sem_test.c
index adfa8c7..e5c7b55 100644
--- a/test/sem_test.c
+++ b/test/sem_test.c
@@ -15,13 +15,13 @@
*/
#include <limits.h>
-#include <pthread.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "zix/sem.h"
+#include "zix/thread.h"
ZixSem sem;
size_t n_signals = 1024;
@@ -68,20 +68,20 @@ main(int argc, char** argv)
zix_sem_init(&sem, 0);
- pthread_t reader_thread;
- if (pthread_create(&reader_thread, NULL, reader, NULL)) {
+ ZixThread reader_thread;
+ if (zix_thread_create(&reader_thread, 128, reader, NULL)) {
fprintf(stderr, "Failed to create reader thread\n");
return 1;
}
- pthread_t writer_thread;
- if (pthread_create(&writer_thread, NULL, writer, NULL)) {
+ ZixThread writer_thread;
+ if (zix_thread_create(&writer_thread, 128, writer, NULL)) {
fprintf(stderr, "Failed to create writer thread\n");
return 1;
}
- pthread_join(reader_thread, NULL);
- pthread_join(writer_thread, NULL);
+ zix_thread_join(reader_thread, NULL);
+ zix_thread_join(writer_thread, NULL);
zix_sem_destroy(&sem);
return 0;