GHOST  1.1.2
General, Hybrid, and Optimized Sparse Toolkit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
thpool.h
Go to the documentation of this file.
1 
7 #ifndef GHOST_THPOOL_H
8 #define GHOST_THPOOL_H
9 
10 #include <pthread.h>
11 #include <semaphore.h>
12 #include <hwloc.h>
13 
14 #include "error.h"
15 
19 typedef struct ghost_thpool {
25  pthread_t *threads;
29  int nThreads;
36  sem_t *sem;
37 } ghost_thpool;
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
56  ghost_error ghost_thpool_create(int nThreads, void *(*func)(void *));
73 
74  ghost_error ghost_thpool_key(pthread_key_t *key);
75 
76  ghost_error ghost_thpoolhread_add(void *(func)(void *), intptr_t arg);
77 
78 
79 #ifdef __cplusplus
80 }
81 #endif
82 
83 #endif
84 
ghost_error ghost_thpool_destroy()
Destroy the thread pool.
Definition: thpool.c:72
ghost_error ghost_thpool_get(ghost_thpool **thpool)
Get the thread pool.
Definition: thpool.c:102
ghost_error ghost_thpoolhread_add(void *(func)(void *), intptr_t arg)
Definition: thpool.c:58
pthread_t * threads
The pthread to thread.
Definition: thpool.h:25
Types, functions and macros for error handling.
ghost_error
Error return type.
Definition: error.h:23
static ghost_thpool * thpool
The thread pool created by ghost_thpool_create().
Definition: thpool.c:15
ghost_error ghost_thpool_create(int nThreads, void *(*func)(void *))
Creates or resizes a thread pool.
int nThreads
The total number of threads in the thread pool.
Definition: thpool.h:29
sem_t * sem
Counts the number of initialized threads.
Definition: thpool.h:36
struct ghost_thpool ghost_thpool
The thread pool consisting of all shepherd threads that will ever handle a GHOST task.
The thread pool consisting of all shepherd threads that will ever handle a GHOST task.
Definition: thpool.h:19
ghost_error ghost_thpool_key(pthread_key_t *key)
Definition: thpool.c:112