Merge: Sys is top
[nit.git] / lib / pthreads / pthreads.nit
index b0be71e..8b8de1f 100644 (file)
 
 # Main POSIX threads support and intro the classes `Thread`, `Mutex` and `Barrier`
 module pthreads is
-       c_compiler_option("-pthread")
-       c_linker_option("-pthread")
+       cflags "-pthread"
+       ldflags "-pthread"
+       pkgconfig "bdw-gc"
+       new_annotation threaded
 end
 
 #
@@ -34,9 +36,10 @@ in "C" `{
        // TODO protect with: #ifdef WITH_LIBGC
        // We might have to add the next line to gc_chooser.c too, especially
        // if we get an error like "thread not registered with GC".
+       #ifndef ANDROID
                #define GC_THREADS
                #include <gc.h>
-       //#endif
+       #endif
 `}
 
 redef class Sys
@@ -114,13 +117,7 @@ private extern class NativePthread in "C" `{ pthread_t * `}
                return (nullable_Object)thread_return;
        `}
 
-       fun attr: NativePthreadAttr `{
-               pthread_attr_t *pattr = malloc(sizeof(pthread_attr_t));
-               pthread_getattr_np(*recv, pattr);
-               return pattr;
-       `}
-
-       fun equal(other: NativePthread): Bool `{ pthread_equal(*recv, *other); `}
+       fun equal(other: NativePthread): Bool `{ return pthread_equal(*recv, *other); `}
 
        fun kill(signal: Int) `{ pthread_kill(*recv, signal); `}
 end
@@ -188,18 +185,6 @@ private extern class NativePthreadMutexAttr in "C" `{ pthread_mutexattr_t * `}
        # pthread_mutexattr_setrobust_np
 end
 
-private extern class NativePthreadBarrier in "C" `{ pthread_barrier_t * `}
-       new(count: Int) `{
-               pthread_barrier_t *barrier = malloc(sizeof(pthread_barrier_t));
-               int res = pthread_barrier_init(barrier, NULL, count);
-               return barrier;
-       `}
-
-       fun destroy `{ pthread_barrier_destroy(recv); `}
-
-       fun wait `{ pthread_barrier_wait(recv); `}
-end
-
 private extern class NativePthreadKey in "C" `{ pthread_key_t * `}
        new `{
                pthread_key_t *key = malloc(sizeof(pthread_key_t));