<commit_before>// RTSemaphore.h

#ifndef RT_SEMAPHORE_H
#define RT_SEMAPHORE_H

#ifdef MACOSX

#include <dispatch/dispatch.h>

class RTSemaphore
{
public:
	RTSemaphore(unsigned inStartingValue=0) : mSema(dispatch_semaphore_create((long)inStartingValue)) {}
	~RTSemaphore() { mSema = NULL; }
	void wait() { dispatch_semaphore_wait(mSema, DISPATCH_TIME_FOREVER); }	// each thread will wait on this
	void post() { dispatch_semaphore_signal(mSema); }	// when done, each thread calls this
private:
	dispatch_semaphore_t	mSema;
};

#else

#include <semaphore.h>

class RTSemaphore
{
public:
	RTSemaphore(unsigned inStartingValue=0) { sem_init(&mSema, 0, inStartingValue); }
	~RTSemaphore() { sem_destroy(&mSema); }
	void wait() { sem_wait(&mSema); }	// each thread will wait on this
	void post() { sem_post(&mSema); }	// when done, each thread calls this
private:
	sem_t	mSema;
};

#endif

#endif	// RT_SEMAPHORE_H
<commit_msg>added check for OSX version, < 10.6 can't use RTSemaphore -- BGG, 2/7/12<commit_after>// RTSemaphore.h

#ifndef RT_SEMAPHORE_H
#define RT_SEMAPHORE_H

#ifdef MACOSX
#include <Availability.h>

#if defined(MACOSX) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060

#include <dispatch/dispatch.h>

class RTSemaphore
{
public:
	RTSemaphore(unsigned inStartingValue=0) : mSema(dispatch_semaphore_create((long)inStartingValue)) {}
	~RTSemaphore() { mSema = NULL; }
	void wait() { dispatch_semaphore_wait(mSema, DISPATCH_TIME_FOREVER); }	// each thread will wait on this
	void post() { dispatch_semaphore_signal(mSema); }	// when done, each thread calls this
private:
	dispatch_semaphore_t	mSema;
};

#else

#include <semaphore.h>

class RTSemaphore
{
public:
	RTSemaphore(unsigned inStartingValue=0) { sem_init(&mSema, 0, inStartingValue); }
	~RTSemaphore() { sem_destroy(&mSema); }
	void wait() { sem_wait(&mSema); }	// each thread will wait on this
	void post() { sem_post(&mSema); }	// when done, each thread calls this
private:
	sem_t	mSema;
};

#endif	// OSX min version
#endif	// MACOSX

#endif	// RT_SEMAPHORE_H

{'fraction_non_alphanumeric': 0.12580167735569808, 'fraction_numerical': 0.008386778490379871, 'mean_word_length': 5.3974763406940065, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2850340', 'n_tokens_mistral': 826, 'n_tokens_neox': 807, 'n_words': 177}