138889Sjdp/* 238889Sjdp * Copyright (c) 2004-2016 Maxim Sobolev <sobomax@FreeBSD.org> 3218822Sdim * All rights reserved. 4218822Sdim * 5218822Sdim * Redistribution and use in source and binary forms, with or without 6130561Sobrien * modification, are permitted provided that the following conditions 7130561Sobrien * are met: 8130561Sobrien * 1. Redistributions of source code must retain the above copyright 938889Sjdp * notice, this list of conditions and the following disclaimer. 10130561Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1138889Sjdp * notice, this list of conditions and the following disclaimer in the 12130561Sobrien * documentation and/or other materials provided with the distribution. 13130561Sobrien * 14130561Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15130561Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16130561Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17130561Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18130561Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19130561Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20130561Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21130561Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22130561Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23130561Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24130561Sobrien * SUCH DAMAGE. 25130561Sobrien * 26130561Sobrien * $FreeBSD$ 27130561Sobrien */ 28130561Sobrien 29130561Sobrienstruct mkuz_fifo_queue { 30130561Sobrien pthread_mutex_t mtx; 31130561Sobrien pthread_cond_t cvar; 32130561Sobrien struct mkuz_bchain_link *first; 33130561Sobrien struct mkuz_bchain_link *last; 34130561Sobrien int length; 35130561Sobrien int wakeup_len; 36130561Sobrien}; 3738889Sjdp 3838889Sjdpstruct mkuz_blk; 3938889Sjdpstruct mkuz_bchain_link; 4038889Sjdp 4138889SjdpDEFINE_RAW_METHOD(cmp_cb, int, const struct mkuz_blk *, void *); 4238889Sjdp 4338889Sjdpstruct mkuz_fifo_queue *mkuz_fqueue_ctor(int); 4438889Sjdpvoid mkuz_fqueue_enq(struct mkuz_fifo_queue *, struct mkuz_blk *); 4538889Sjdpstruct mkuz_blk *mkuz_fqueue_deq(struct mkuz_fifo_queue *); 4638889Sjdpstruct mkuz_blk *mkuz_fqueue_deq_when(struct mkuz_fifo_queue *, cmp_cb_t, void *); 4738889Sjdp#if defined(NOTYET) 4838889Sjdpstruct mkuz_bchain_link *mkuz_fqueue_deq_all(struct mkuz_fifo_queue *, int *); 4938889Sjdpint mkuz_fqueue_enq_all(struct mkuz_fifo_queue *, struct mkuz_bchain_link *, 5038889Sjdp struct mkuz_bchain_link *, int); 5138889Sjdp#endif 5238889Sjdp