1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  14  */
  15 
  16 #ifndef _KRRP_QUEUE_H
  17 #define _KRRP_QUEUE_H
  18 
  19 #include <sys/sysmacros.h>
  20 #include <sys/kmem.h>
  21 #include <sys/stream.h>
  22 #include <sys/list.h>
  23 #include <sys/modctl.h>
  24 #include <sys/class.h>
  25 #include <sys/cmn_err.h>
  26 
  27 #ifdef __cplusplus
  28 extern "C" {
  29 #endif
  30 
  31 typedef struct krrp_queue_s {
  32         kmutex_t                mtx;
  33         kcondvar_t              cv;
  34         list_t                  list;
  35         size_t                  cnt;
  36         boolean_t               force_return;
  37 } krrp_queue_t;
  38 
  39 void krrp_queue_init(krrp_queue_t **, size_t, size_t);
  40 void krrp_queue_fini(krrp_queue_t *);
  41 size_t krrp_queue_length(krrp_queue_t *);
  42 void krrp_queue_set_force_return(krrp_queue_t *);
  43 void krrp_queue_put(krrp_queue_t *, void *);
  44 void *krrp_queue_get(krrp_queue_t *);
  45 void *krrp_queue_get_no_wait(krrp_queue_t *);
  46 
  47 #ifdef __cplusplus
  48 }
  49 #endif
  50 
  51 #endif /* _KRRP_QUEUE_H */