File: barriers.h

package info (click to toggle)
libinotify-kqueue 20120419-1
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 404 kB
  • sloc: ansic: 1,902; cpp: 1,430; makefile: 69; sh: 1
file content (30 lines) | stat: -rw-r--r-- 829 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef __BARRIERS_H__
#define __BARRIERS_H__

#include <pthread.h>

typedef struct {
    int count;               /* the number of threads to wait on a barrier */
    volatile int sleeping;   /* the number of threads sleeping on a barrier */
    volatile int passed;     /* a boolean flag showing if the barrier is 
                                passed or not */ 

    pthread_mutex_t mtx;     /* barrier's internal mutex.. */
    pthread_cond_t  cnd;     /* ..and a condition variable */
} ik_barrier_impl;

#define WITHOUT_BARRIERS

typedef struct {
#ifndef WITHOUT_BARRIERS    
    pthread_barrier_t impl;
#else
    ik_barrier_impl impl;
#endif    
} ik_barrier;

void ik_barrier_init    (ik_barrier *b, int n);
void ik_barrier_wait    (ik_barrier *b);
void ik_barrier_destroy (ik_barrier *b);

#endif /* __BARRIERS_H__ */