Files
SRB2Kart-Saturn/src/i_threads.h
T
Alug 0985229077 refactor i_thread stuff
based on https://codeberg.org/srb2classic/srb2classic/commit/3670a7c1c193185cf4921de8955c96e63fbecc62
and other things from srb2classic
this also now allows to check if a thread failed to spawn and reduces duped stuff and such
2026-02-02 16:54:40 +01:00

60 lines
1.3 KiB
C

// SONIC ROBO BLAST 2 KART
//-----------------------------------------------------------------------------
// Copyright (C) 2020-2023 by James R.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file i_threads.h
/// \brief Multithreading abstraction
#ifdef HAVE_THREADS
#ifndef I_THREADS_H
#define I_THREADS_H
#include "doomtype.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*I_ThreadFn)(void *userdata);
typedef void * I_Mutex;
typedef void * I_Cond;
#ifdef __linux__
typedef long unsigned int thread_handle_t;
#else
typedef void *thread_handle_t;
#endif
void I_StartThreads (void);
void I_StopThreads (void);
FUNCWARNRV
int I_SpawnThread (const char *name, I_ThreadFn, void *userdata);
/* check in your thread whether to return early */
int I_ThreadIsStopped (void);
void I_LockMutex (I_Mutex *);
void I_UnlockMutex (I_Mutex);
void I_HoldCond (I_Cond *, I_Mutex);
void I_WakeOneCond (I_Cond *);
void I_WakeAllCond (I_Cond *);
thread_handle_t I_GetCurrentThread(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif/*I_THREADS_H*/
#endif/*HAVE_THREADS*/