Reader-writer queue locks
[akaros.git] / kern / include / apipe.h
index bb63ca5..bbbb231 100644 (file)
@@ -63,12 +63,18 @@ struct atomic_pipe {
        size_t                                          ap_wr_off;
        unsigned int                            ap_nr_readers;
        unsigned int                            ap_nr_writers;
-       struct cond_var                         ap_cv;
+       spinlock_t                                      ap_lock;
+       struct cond_var                         ap_priority_reader;
+       struct cond_var                         ap_general_readers;
+       struct cond_var                         ap_writers;
+       bool                                            ap_has_priority_reader;
 };
 
 void apipe_init(struct atomic_pipe *ap, void *buf, size_t buf_sz,
                 size_t elem_sz);
 int apipe_read(struct atomic_pipe *ap, void *buf, size_t nr_elem);
+int apipe_read_cond(struct atomic_pipe *ap,
+                   int(*f)(struct atomic_pipe *pipe, void *arg), void *arg);
 int apipe_write(struct atomic_pipe *ap, void *buf, size_t nr_elem);
 void *apipe_head(struct atomic_pipe *ap);