Added class to abstract away platform specific thread primitives.

This commit is contained in:
Michael Bebenita 2010-08-09 07:42:06 -07:00
parent 56cd4e458a
commit 9ff6a3d031
3 changed files with 25 additions and 2 deletions

View File

@ -245,7 +245,8 @@ BOOT_CMXS := $(BOOT_MLS:.ml=.cmx)
BOOT_OBJS := $(BOOT_MLS:.ml=.o)
BOOT_CMIS := $(BOOT_MLS:.ml=.cmi)
RUNTIME_CS := rt/sync/spin_lock.cpp \
RUNTIME_CS := rt/sync/sync.cpp \
rt/sync/spin_lock.cpp \
rt/sync/lock_free_queue.cpp \
rt/sync/condition_variable.cpp \
rt/rust.cpp \
@ -279,7 +280,8 @@ RUNTIME_HDR := rt/globals.h \
rt/rust_message.h \
rt/circular_buffer.h \
rt/util/array_list.h \
rt/util/hash_map.h
rt/util/hash_map.h \
rt/sync/sync.h
RUNTIME_INCS := -Irt/isaac -Irt/uthash
RUNTIME_OBJS := $(RUNTIME_CS:.cpp=$(CFG_OBJ_SUFFIX))

12
src/rt/sync/sync.cpp Normal file
View File

@ -0,0 +1,12 @@
#include "../globals.h"
#include "sync.h"
void sync::yield() {
#ifdef __APPLE__
pthread_yield_np();
#elif __WIN32__
#else
pthread_yield();
#endif
}

9
src/rt/sync/sync.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef SYNC_H
#define SYNC_H
class sync {
public:
static void yield();
};
#endif /* SYNC_H */