1303095Ssobomax/* 2303095Ssobomax * Copyright (c) 2004-2016 Maxim Sobolev <sobomax@FreeBSD.org> 3303095Ssobomax * All rights reserved. 4303095Ssobomax * 5303095Ssobomax * Redistribution and use in source and binary forms, with or without 6303095Ssobomax * modification, are permitted provided that the following conditions 7303095Ssobomax * are met: 8303095Ssobomax * 1. Redistributions of source code must retain the above copyright 9303095Ssobomax * notice, this list of conditions and the following disclaimer. 10303095Ssobomax * 2. Redistributions in binary form must reproduce the above copyright 11303095Ssobomax * notice, this list of conditions and the following disclaimer in the 12303095Ssobomax * documentation and/or other materials provided with the distribution. 13303095Ssobomax * 14303095Ssobomax * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15303095Ssobomax * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16303095Ssobomax * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17303095Ssobomax * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18303095Ssobomax * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19303095Ssobomax * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20303095Ssobomax * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21303095Ssobomax * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22303095Ssobomax * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23303095Ssobomax * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24303095Ssobomax * SUCH DAMAGE. 25303095Ssobomax * 26303095Ssobomax * $FreeBSD$ 27303095Ssobomax */ 28303095Ssobomax 29303095Ssobomaxstruct mkuz_fifo_queue { 30303095Ssobomax pthread_mutex_t mtx; 31303095Ssobomax pthread_cond_t cvar; 32303095Ssobomax struct mkuz_bchain_link *first; 33303095Ssobomax struct mkuz_bchain_link *last; 34303095Ssobomax int length; 35303095Ssobomax int wakeup_len; 36303095Ssobomax}; 37303095Ssobomax 38303095Ssobomaxstruct mkuz_blk; 39303095Ssobomaxstruct mkuz_bchain_link; 40303095Ssobomax 41303095SsobomaxDEFINE_RAW_METHOD(cmp_cb, int, const struct mkuz_blk *, void *); 42303095Ssobomax 43303095Ssobomaxstruct mkuz_fifo_queue *mkuz_fqueue_ctor(int); 44303095Ssobomaxvoid mkuz_fqueue_enq(struct mkuz_fifo_queue *, struct mkuz_blk *); 45303095Ssobomaxstruct mkuz_blk *mkuz_fqueue_deq(struct mkuz_fifo_queue *); 46303095Ssobomaxstruct mkuz_blk *mkuz_fqueue_deq_when(struct mkuz_fifo_queue *, cmp_cb_t, void *); 47303095Ssobomax#if defined(NOTYET) 48303095Ssobomaxstruct mkuz_bchain_link *mkuz_fqueue_deq_all(struct mkuz_fifo_queue *, int *); 49303095Ssobomaxint mkuz_fqueue_enq_all(struct mkuz_fifo_queue *, struct mkuz_bchain_link *, 50303095Ssobomax struct mkuz_bchain_link *, int); 51303095Ssobomax#endif 52