/* ************************************************************************ ** ** Copyright (c) 2010 by ** Core|Vision B.V. ** Cereslaan 10b ** 5384 VT Heesch ** The Netherlands ** ** All Rights Reserved ** ************************************************************************ */ /* ************************************************************************ ** ** Project name: Dual Inventive: Utility Library ** Filename: cp3000-thread.h ** Author: Jack Weeland ** Date: February 26, 2010 ** File version: 1.00 of February 26, 2010 ** ************************************************************************ */ /* ************************************************************************ ** ** CP3000 multi-threading ** ************************************************************************ */ #ifndef __CP3000_THREAD_H #define __CP3000_THREAD_H #include // for struct timeval /* ** Type definitions */ // structure to hold information about a thread typedef struct CP3000_THREAD_CTX *cp3000_thread_t; // thread function; called when the thread is started typedef int (*cp3000_thread_fcn_t)(void*); // mutex (locally to a process) typedef struct CP3000_THREAD_MUTEX *cp3000_mutex_t; /* ** Exported functions - threads */ // Start a thread cp3000_thread_t cp3000_start_thread(cp3000_thread_fcn_t, void *args); // Destroy a thread int cp3000_destroy_thread(cp3000_thread_t); // Wait for a thread to end // Parameters: // thread context // time-out (or NULL if time-out not requested) // Returns: // Return value from the thread functions, or TCPERR_TIMEOUT when the // time-out expired int cp3000_wait_thread(cp3000_thread_t, struct timeval*); // Get thread exit status and run time int cp3000_get_thread_exit(cp3000_thread_t); int cp3000_get_thread_time(cp3000_thread_t, struct timeval*); /* ** Exported functions - mutexes */ // Create and destroy a mutex cp3000_mutex_t cp3000_init_mutex(); int cp3000_destroy_mutex(cp3000_mutex_t); // Locking and unlocking (return value is not very interesting) int cp3000_lock_mutex(cp3000_mutex_t); int cp3000_unlock_mutex(cp3000_mutex_t); #endif /* __CP3000_THREAD_H */