bunkum

an old and silly c99 web server with some fun features
Log | Files | Refs | README

sync.h (404B)


      1 #ifndef UTIL_SYNC_H
      2 #define UTIL_SYNC_H
      3 
      4 #include <pthread.h>
      5 #include "vec.h"
      6 
      7 typedef struct channel {
      8     pthread_mutex_t mutex;
      9     vec_t queue;
     10     size_t msg_sz;
     11     size_t sz;
     12 } channel_t;
     13 
     14 channel_t channel_new(size_t msg_sz);
     15 void channel_push(channel_t* chan, void* msg);
     16 void* channel_pop(channel_t* chan);
     17 void* channel_recv(channel_t* chan);
     18 void* channel_try_recv(channel_t* chan);
     19 
     20 #endif