BFLibC 0.1
C Library
Loading...
Searching...
No Matches
thread.h File Reference
#include <stdbool.h>
#include "typethreadid.h"
Include dependency graph for thread.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int BFThreadGetStartedCount ()
 
void BFThreadResetStartedCount ()
 
int BFThreadGetStoppedCount ()
 
void BFThreadResetStoppedCount ()
 
int BFThreadSync (void(*callback)(void *), void *args)
 
 __attribute__ ((deprecated("detach state is now the default behavior. this function is no longer supported"))) int BFThreadAsyncDetach(void(*callback)(void *)
 
BFThreadAsyncID BFThreadAsync (void(*callback)(void *), void *args)
 
bool BFThreadAsyncIDIsValid (BFThreadAsyncID)
 
const BFThreadAsyncID BFThreadAsyncGetID ()
 
void BFThreadAsyncDestroy (BFThreadAsyncID in)
 
int BFThreadAsyncError (BFThreadAsyncID)
 
bool BFThreadAsyncIsRunning (BFThreadAsyncID)
 
int BFThreadAsyncCancel (BFThreadAsyncID)
 
bool BFThreadAsyncIsCanceled (BFThreadAsyncID)
 
int BFThreadAsyncWait (BFThreadAsyncID)
 

Variables

void * args
 

Function Documentation

◆ __attribute__()

__attribute__ ( (deprecated("detach state is now the default behavior. this function is no longer supported")) )

Launches an async thread and detaches thread

If you want to manage and query an async thread, please consider using BFThreadAsync

NOTICE: this funciton will do nothing

◆ BFThreadAsync()

BFThreadAsyncID BFThreadAsync ( void(* callback )(void *),
void * args )

Launches and detaches callback on a separate thread

will return while thread is running

us async id to query the async thread

To destroy use BFThreadAsyncIDDestroy

Here is the call graph for this function:

◆ BFThreadAsyncCancel()

int BFThreadAsyncCancel ( BFThreadAsyncID in)

Sets a flag that is readable

If called, BFThreadAsyncIsCanceled will always return true

The result of the function is not reversible

◆ BFThreadAsyncDestroy()

void BFThreadAsyncDestroy ( BFThreadAsyncID in)

Releases BFThreadAsyncID

Here is the call graph for this function:

◆ BFThreadAsyncError()

int BFThreadAsyncError ( BFThreadAsyncID id)

returns the error code, if any, for BFThreadAsync

◆ BFThreadAsyncGetID()

const BFThreadAsyncID BFThreadAsyncGetID ( )

returns current thread id

caller is not responsible for the memory

returns 0 if there was an error

Here is the call graph for this function:

◆ BFThreadAsyncIDIsValid()

bool BFThreadAsyncIDIsValid ( BFThreadAsyncID id)

true if we can safely use id

◆ BFThreadAsyncIsCanceled()

bool BFThreadAsyncIsCanceled ( BFThreadAsyncID in)

If thread has been canceled

caller can safely call this on running thread

◆ BFThreadAsyncIsRunning()

bool BFThreadAsyncIsRunning ( BFThreadAsyncID in)

true if callback from BFThreadAsync is still running

thread safe. you can use this function to poll the async thread if it's still running

◆ BFThreadAsyncWait()

int BFThreadAsyncWait ( BFThreadAsyncID in)

Waits for thread to finished if BFThreadAsyncIsRunning is true

this will block function until thread is finished

be careful when you call this. be sure that you know the thread WILL end soon or else this will hang

Here is the call graph for this function:

◆ BFThreadGetStartedCount()

int BFThreadGetStartedCount ( )

author: brando date: 10/20/23 returns the count of how many sync/async threads have been launched in current process

◆ BFThreadGetStoppedCount()

int BFThreadGetStoppedCount ( )

returns the count of how many sync/async threads have been finished in current process

◆ BFThreadResetStartedCount()

void BFThreadResetStartedCount ( )

resets the thread launch count

◆ BFThreadResetStoppedCount()

void BFThreadResetStoppedCount ( )

resets the thread stop count

◆ BFThreadSync()

int BFThreadSync ( void(* callback )(void *),
void * args )

Launches thread and returns when thread terminates

Here is the call graph for this function:

Variable Documentation

◆ args

void* args