mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-08-31 00:40:16 +00:00
This adds generic APIs to libqb for handling thread's, mutex's, and condition variables. On Linux and OSX these are implemented via the ones provided by pthreads. On Windows they're implemented via the ones provided by the Win32 API. For compiling, the code itself is not conditional, but the Makefile includes logic to decide which implementation to pick. Note that it would have been nice to simply use std::thread and friends from C++11, however using them on MinGW appears to be a bit messy. Since using the Windows ones directly isn't that hard this was an easy compromise.
18 lines
562 B
C
18 lines
562 B
C
#ifndef INCLUDE_LIBQB_THREAD_H
|
|
#define INCLUDE_LIBQB_THREAD_H
|
|
|
|
// Thread
|
|
struct libqb_thread;
|
|
|
|
// Allocates a new thread, note that it is not running when this returns
|
|
// Thread should already be stopped/joined when free is called
|
|
struct libqb_thread *libqb_thread_new();
|
|
void libqb_thread_free(struct libqb_thread *);
|
|
|
|
// Configures and starts a thread to begin it's execution.
|
|
void libqb_thread_start(struct libqb_thread *, void (*start_func) (void *), void *arg);
|
|
|
|
// Joins a thread to end its execution
|
|
void libqb_thread_join(struct libqb_thread *);
|
|
|
|
#endif
|