libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_thread.h File Reference

Go to the source code of this file.

Data Structures

struct  GblThreadClass
 
struct  GblThread
 

Macros

Type System

Type UUID and cast operators

#define GBL_THREAD_TYPE
 
#define GBL_THREAD(self)
 
#define GBL_THREAD_CLASS(klass)
 
#define GBL_THREAD_GET_CLASS(self)
 
Function Overload Macros

Macros providing default arguments for methods

Typedefs

typedef GBL_RESULT(* GblThreadFn) (GblThread *pSelf)
 
typedef GblBool(* GblThreadIterFn) (GblThread *pSelf, void *pClosure)
 
typedef uintptr_t GblThreadAffinity
 
typedef GblEnum GBL_THREAD_PRIORITY
 
typedef GblEnum GBL_THREAD_STATE
 

Enumerations

enum  GBL_THREAD_PRIORITY
 
enum  GBL_THREAD_STATE
 

Functions

Static Methods

Searching, iterating, counting, etc.

GblType GblThread_type (void)
 
size_t GblThread_count (void)
 
GblThreadGblThread_find (const char *pName)
 
GblBool GblThread_foreach (GblThreadIterFn pIt, void *pCl)
 

Detailed Description

GblThread and lowest-level concurrency managment.

This file contains the API and public structures for GblThread, the lowest-level construct for concurrent task execution, directly mapping to an OS-level thread. The API is backed by either C11 threads, POSIX pthreads, or Win32 threads, depending on the platform.

Todo:
  • properties
  • GblThread_setCallback() has to store within GblBox field
  • GblThread_setClosure() has to store within GblBox field WITH DTOR
  • GblArrayMap for underlying structure doesn't make sensse, use GblArrayList
  • need code for adding and removing to/from vector
  • checking for auto invocation upon constructed won't work–hasn't been set yet
Author
2023 Falco Girgis

Definition in file gimbal_thread.h.

Macro Definition Documentation

◆ GBL_THREAD_TYPE

#define GBL_THREAD_TYPE

Type UUID for GblThread.

Definition at line 35 of file gimbal_thread.h.

◆ GBL_THREAD

#define GBL_THREAD (   self)

Function-style GblInstance cast.

Definition at line 36 of file gimbal_thread.h.

◆ GBL_THREAD_CLASS

#define GBL_THREAD_CLASS (   klass)

Function-style GblClass cast.

Definition at line 37 of file gimbal_thread.h.

◆ GBL_THREAD_GET_CLASS

#define GBL_THREAD_GET_CLASS (   self)

Get GblThreadClass from GblInstance.

Definition at line 38 of file gimbal_thread.h.

Typedef Documentation

◆ GblThreadFn

typedef GBL_RESULT(* GblThreadFn) (GblThread *pSelf)

Function callback type to be used as the main thread's callback with GblThread_setCallback().

Definition at line 49 of file gimbal_thread.h.

◆ GblThreadIterFn

typedef GblBool(* GblThreadIterFn) (GblThread *pSelf, void *pClosure)

Iterator function type to be used with GblThread_foreach()

Definition at line 51 of file gimbal_thread.h.

◆ GblThreadAffinity

typedef uintptr_t GblThreadAffinity

Represents a CPU affinity bitmask, with each bit being affinity to a single core.

Definition at line 53 of file gimbal_thread.h.

◆ GBL_THREAD_PRIORITY

Priority levels for GblThread.

Definition at line 56 of file gimbal_thread.h.

◆ GBL_THREAD_STATE

Lifetime states for a GblThread.

Definition at line 64 of file gimbal_thread.h.

Enumeration Type Documentation

◆ GBL_THREAD_PRIORITY

Enumerator
GBL_THREAD_PRIORITY_LOW 

Lowest.

GBL_THREAD_PRIORITY_MEDIUM 

Medium.

GBL_THREAD_PRIORITY_HIGH 

High.

GBL_THREAD_PRIORITY_REAL_TIME 

Highest.

Definition at line 56 of file gimbal_thread.h.

56 {
57 GBL_THREAD_PRIORITY_LOW, //!< Lowest
61};
@ GBL_THREAD_PRIORITY_MEDIUM
Medium.
@ GBL_THREAD_PRIORITY_LOW
Lowest.
@ GBL_THREAD_PRIORITY_HIGH
High.
@ GBL_THREAD_PRIORITY_REAL_TIME
Highest.

◆ GBL_THREAD_STATE

Enumerator
GBL_THREAD_STATE_UNKNOWN 

Unknown.

GBL_THREAD_STATE_INITIALIZING 

Initializing/Constructing.

GBL_THREAD_STATE_READY 

Ready/Waiting.

GBL_THREAD_STATE_RUNNING 

Running/Executing.

GBL_THREAD_STATE_FINISHED 

Finished/Completed.

Definition at line 64 of file gimbal_thread.h.

64 {
65 GBL_THREAD_STATE_UNKNOWN, //!< Unknown
66 GBL_THREAD_STATE_INITIALIZING, //!< Initializing/Constructing
67 GBL_THREAD_STATE_READY, //!< Ready/Waiting
68 GBL_THREAD_STATE_RUNNING, //!< Running/Executing
69 GBL_THREAD_STATE_FINISHED //!< Finished/Completed
70};
@ GBL_THREAD_STATE_RUNNING
Running/Executing.
@ GBL_THREAD_STATE_FINISHED
Finished/Completed.
@ GBL_THREAD_STATE_INITIALIZING
Initializing/Constructing.
@ GBL_THREAD_STATE_UNKNOWN
Unknown.
@ GBL_THREAD_STATE_READY
Ready/Waiting.

Function Documentation

◆ GblThread_type()

GblType GblThread_type ( void  )

Returns the GblType UUID associated with GblThread.

◆ GblThread_count()

size_t GblThread_count ( void  )

Returns the current number of live threads (not necessarily all active)

◆ GblThread_find()

GblThread * GblThread_find ( const char *  pName)

Searches (linearly) for a thread with the string name given by pName.

◆ GblThread_foreach()

GblBool GblThread_foreach ( GblThreadIterFn  pIt,
void *  pCl 
)

Iterates over all live threads, passing each thread and pCl back to the pIt callback.