Added global LAM bool variable (lam_uses_threads) to indicate level
of thread support expected in current job, an inlined macro to access this parameter, and macros to support locking/unlocking (THREAD_X and X). This commit was SVN r229.
Этот коммит содержится в:
родитель
2813374b04
Коммит
a6ba6797ab
@ -17,6 +17,7 @@ headers = \
|
||||
|
||||
libthreads_la_SOURCES = \
|
||||
$(headers) \
|
||||
mutex.c \
|
||||
thread.c
|
||||
|
||||
# Conditionally install the header files
|
||||
|
8
src/lam/threads/mutex.c
Обычный файл
8
src/lam/threads/mutex.c
Обычный файл
@ -0,0 +1,8 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "lam/threads/mutex.h"
|
||||
|
||||
bool lam_uses_threads;
|
||||
|
@ -5,10 +5,33 @@
|
||||
#ifndef _MUTEX_H_
|
||||
#define _MUTEX_H_
|
||||
|
||||
#include "lam_config.h"
|
||||
|
||||
#if defined(USE_SPINWAIT)
|
||||
#include "lam/threads/mutex_spinwait.h"
|
||||
#else
|
||||
#include "lam/threads/mutex_spinlock.h"
|
||||
#endif
|
||||
|
||||
extern bool lam_uses_threads;
|
||||
|
||||
static inline bool lam_use_threads() { return lam_uses_threads; }
|
||||
|
||||
/*
|
||||
* Lock macros
|
||||
*/
|
||||
#define THREAD_LOCK(a) if(lam_use_threads()) \
|
||||
lam_mtx_lock((a));
|
||||
|
||||
#define LOCK(a) lam_mtx_lock((a))
|
||||
|
||||
/*
|
||||
* unlock macros
|
||||
*/
|
||||
#define THREAD_UNLOCK(a) if(lam_use_threads()) \
|
||||
lam_mtx_unlock((a));
|
||||
|
||||
#define UNLOCK(a) lam_mtx_unlock((a));
|
||||
|
||||
#endif
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user