aboutsummaryrefslogblamecommitdiff
path: root/src/common/mythread.h
blob: cd9ae89ab4f70e3f7a485f17d25615e4a2074918 (plain) (tree)

































                                                                               
///////////////////////////////////////////////////////////////////////////////
//
/// \file       mythread.h
/// \brief      Wrappers for threads
//
//  Author: Lasse Collin
//  This file has been put into the public domain.
//
///////////////////////////////////////////////////////////////////////////////

#include "sysdefs.h"


#ifdef HAVE_PTHREAD
#	include <pthread.h>

#	define mythread_once(func) \
	do { \
		static pthread_once_t once_ = PTHREAD_ONCE_INIT; \
		pthread_once(&once_, &func); \
	} while (0)

#else

#	define mythread_once(func) \
	do { \
		static bool once_ = false; \
		if (!once_) { \
			func(); \
			once_ = true; \
		} \
	} while (0)

#endif