queue/mn_queue.hpp
Go to the documentation of this file.
1 /*
2 *This file is part of the Mini Thread Library (https://github.com/RoseLeBlood/MiniThread ).
3 *Copyright (c) 2020 Amber-Sophia Schroeck
4 *
5 *The Mini Thread Library is free software; you can redistribute it and/or modify
6 *it under the terms of the GNU Lesser General Public License as published by
7 *the Free Software Foundation, version 3, or (at your option) any later version.
8 
9 *The Mini Thread Library is distributed in the hope that it will be useful, but
10 *WITHOUT ANY WARRANTY; without even the implied warranty of
11 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 *General Public License for more details.
13 *
14 *You should have received a copy of the GNU Lesser General Public
15 *License along with the Mini Thread Library; if not, see
16 *<https://www.gnu.org/licenses/>.
17 */
18 #ifndef MINLIB_ESP32_QUEUE_
19 #define MINLIB_ESP32_QUEUE_
20 
21 #include "mn_config.hpp"
22 
23 namespace mn {
24  namespace queue {
31  class basic_queue {
32  public:
39  basic_queue(unsigned int maxItems, unsigned int itemSize);
40 
44  virtual ~basic_queue();
45 
55  virtual int create();
56 
63  virtual int destroy();
72  virtual int enqueue(void *item,
73  unsigned int timeout = MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT);
74 
75 
85  virtual int peek(void *item,
86  unsigned int timeout = MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT);
87 
96  virtual int dequeue(void *item,
97  unsigned int timeout = MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT);
98 
103  virtual bool is_empty();
108  virtual bool is_full();
109 
113  virtual int clear();
114 
119  virtual unsigned int get_num_items();
120 
125  virtual unsigned int get_left();
126 
131  void* get_handle() { return m_pHandle; }
132  protected:
136  void* m_pHandle;
137 
138  unsigned int m_imaxItems;
139  unsigned int m_iitemSize;
140  };
141 
143  }
144 }
145 
146 #endif
Queue class wrapper for FreeRTOS queues.
Definition: queue/mn_queue.hpp:31
void * m_pHandle
Definition: queue/mn_queue.hpp:136
unsigned int m_iitemSize
Definition: queue/mn_queue.hpp:139
virtual int enqueue(void *item, unsigned int timeout=MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT)
Definition: mn_queue.cpp:50
virtual bool is_full()
Definition: mn_queue.cpp:105
virtual unsigned int get_num_items()
Definition: mn_queue.cpp:117
virtual ~basic_queue()
Definition: mn_queue.cpp:30
virtual int peek(void *item, unsigned int timeout=MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT)
Definition: mn_queue.cpp:86
basic_queue(unsigned int maxItems, unsigned int itemSize)
Definition: mn_queue.cpp:26
virtual int destroy()
Definition: mn_queue.cpp:41
virtual bool is_empty()
Definition: mn_queue.cpp:100
virtual int clear()
Definition: mn_queue.cpp:111
virtual int create()
Definition: mn_queue.cpp:34
unsigned int m_imaxItems
Definition: queue/mn_queue.hpp:138
void * get_handle()
Definition: queue/mn_queue.hpp:131
virtual unsigned int get_left()
Definition: mn_queue.cpp:122
virtual int dequeue(void *item, unsigned int timeout=MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT)
Definition: mn_queue.cpp:68
#define MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT
Definition: mn_config.hpp:387
basic_queue< T, TMAXITEMS, TITEMSIZE > queue
Definition: container/mn_queue.hpp:239
Definition: mn_allocator_typetraits.hpp:25