medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit e07546f3bef49967da0d3c46c9831631c9f3f043
parent 671dc48ddc31000c7b8e03a3f0346bc2c824f12c
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Tue Dec 15 19:36:42 +0000

Add macros for thread definitions/endpoints

Diffstat:
linux_audio.cc | 4++--
unix_thread.cc | 3+++
work_queue.cc | 4++--
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/linux_audio.cc b/linux_audio.cc @@ -19,7 +19,7 @@ static int milliseconds( int ms ) { static u32 sample_rate; -static void * mix_worker( void * data ) { +static THREAD( mix_worker ) { snd_pcm_t * pcm = ( snd_pcm_t * ) data; s16 samples[ 4096 ]; @@ -45,7 +45,7 @@ static void * mix_worker( void * data ) { } } - return nullptr; + THREAD_END; } static void error_handler( const char * file, int line, const char * function, int err, const char * fmt, ... ) { diff --git a/unix_thread.cc b/unix_thread.cc @@ -1,6 +1,9 @@ #include <err.h> #include <pthread.h> +#define THREAD( f ) void * f( void * data ) +#define THREAD_END return NULL + struct Thread { pthread_t pthread; }; diff --git a/work_queue.cc b/work_queue.cc @@ -29,7 +29,7 @@ static bool workqueue_step( const u32 thread_id, WorkQueue * const queue ) { return false; } -static void * workqueue_worker( void * const data ) { +static THREAD( workqueue_worker ) { ThreadInfo * const info = ( ThreadInfo * const ) data; WorkQueue * const queue = info->queue; @@ -44,7 +44,7 @@ static void * workqueue_worker( void * const data ) { } } - return nullptr; + THREAD_END; } void workqueue_init( WorkQueue * const queue, MemoryArena * const arena, const u32 num_threads ) {