mirror of
https://github.com/TheOnlyZac/sly1.git
synced 2024-11-26 23:20:43 +00:00
59 lines
967 B
C
59 lines
967 B
C
/**
|
|
* @file thread.h
|
|
*
|
|
* @brief Semaphore, thread, and critical section utilities.
|
|
*/
|
|
#ifndef THREAD_H
|
|
#define THREAD_H
|
|
|
|
#include "common.h"
|
|
|
|
/**
|
|
* @brief Details for a critical section
|
|
*/
|
|
struct CRITSECT
|
|
{
|
|
int cEnter;
|
|
int thread;
|
|
int sema;
|
|
};
|
|
|
|
/**
|
|
* @brief Create a semaphore.
|
|
*
|
|
* @param initCount Initial count.
|
|
* @param maxCount Maximum count.
|
|
* @return The semaphore ID.
|
|
*/
|
|
int SemaCreate(int initCount, int maxCount);
|
|
|
|
/**
|
|
* @brief Initialize a critical section.
|
|
*
|
|
* @param pcritsect Critical section.
|
|
*/
|
|
void InitCritSect(CRITSECT* pcritsect);
|
|
|
|
/**
|
|
* @brief Enter a critical section.
|
|
*
|
|
* @param pcritsect Critical section.
|
|
*/
|
|
void EnterCritSect(CRITSECT* pcritsect);
|
|
|
|
/**
|
|
* @brief Leave a critical section.
|
|
*
|
|
* @param pcritsect Critical section.
|
|
*/
|
|
void LeaveCritSect(CRITSECT* pcritsect);
|
|
|
|
/**
|
|
* @brief Initialize parameters for a rendering thread.
|
|
*/
|
|
void StartupThread();
|
|
|
|
extern CRITSECT g_athread;
|
|
|
|
#endif // THREAD_H
|