librace: format DEBUG() prints properly
[c11tester.git] / threads.h
index 7427eeb59747322195a05ad418adae4a788f2645..44e1013768e911c6aaec6aa8564fd2a629b94cc7 100644 (file)
--- a/threads.h
+++ b/threads.h
@@ -5,6 +5,8 @@
 
 #include "libthreads.h"
 
+#define THREAD_ID_T_NONE       -1
+
 typedef enum thread_state {
        THREAD_CREATED,
        THREAD_RUNNING,
@@ -12,19 +14,19 @@ typedef enum thread_state {
        THREAD_COMPLETED
 } thread_state;
 
-class ModelAction;
-
 class Thread {
 public:
+       void * operator new(size_t size);
+       void operator delete(void *ptr);
        Thread(thrd_t *t, void (*func)(), void *a);
        Thread(thrd_t *t);
+       ~Thread();
+       void complete();
        int swap(Thread *t);
-       void dispose();
 
        thread_state get_state() { return state; }
        void set_state(thread_state s) { state = s; }
        thread_id_t get_id();
-       void set_id(thread_id_t i) { *user_thread = i; }
        thrd_t get_thrd_t() { return *user_thread; }
 private:
        int create_context();
@@ -34,10 +36,11 @@ private:
        ucontext_t context;
        void *stack;
        thrd_t *user_thread;
+       thread_id_t id;
        thread_state state;
 };
 
-Thread *thread_current();
+Thread * thread_current();
 
 static inline thread_id_t thrd_to_id(thrd_t t)
 {