blob: a19fe78e3a0164f3fddfbe8e0ddc775c8b84501e [file] [log] [blame]
Antoine Pitrou94e16962018-01-16 00:27:16 +01001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(simplequeue_new__doc__,
6"SimpleQueue()\n"
7"--\n"
8"\n"
9"Simple, unbounded, reentrant FIFO queue.");
10
11static PyObject *
12simplequeue_new_impl(PyTypeObject *type);
13
14static PyObject *
15simplequeue_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
16{
17 PyObject *return_value = NULL;
18
19 if ((type == &PySimpleQueueType) &&
20 !_PyArg_NoPositional("SimpleQueue", args)) {
21 goto exit;
22 }
23 if ((type == &PySimpleQueueType) &&
24 !_PyArg_NoKeywords("SimpleQueue", kwargs)) {
25 goto exit;
26 }
27 return_value = simplequeue_new_impl(type);
28
29exit:
30 return return_value;
31}
32
33PyDoc_STRVAR(_queue_SimpleQueue_put__doc__,
34"put($self, /, item, block=True, timeout=None)\n"
35"--\n"
36"\n"
37"Put the item on the queue.\n"
38"\n"
39"The optional \'block\' and \'timeout\' arguments are ignored, as this method\n"
40"never blocks. They are provided for compatibility with the Queue class.");
41
42#define _QUEUE_SIMPLEQUEUE_PUT_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +020043 {"put", (PyCFunction)(void(*)(void))_queue_SimpleQueue_put, METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_put__doc__},
Antoine Pitrou94e16962018-01-16 00:27:16 +010044
45static PyObject *
46_queue_SimpleQueue_put_impl(simplequeueobject *self, PyObject *item,
47 int block, PyObject *timeout);
48
49static PyObject *
50_queue_SimpleQueue_put(simplequeueobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
51{
52 PyObject *return_value = NULL;
53 static const char * const _keywords[] = {"item", "block", "timeout", NULL};
54 static _PyArg_Parser _parser = {"O|pO:put", _keywords, 0};
55 PyObject *item;
56 int block = 1;
57 PyObject *timeout = Py_None;
58
59 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
60 &item, &block, &timeout)) {
61 goto exit;
62 }
63 return_value = _queue_SimpleQueue_put_impl(self, item, block, timeout);
64
65exit:
66 return return_value;
67}
68
69PyDoc_STRVAR(_queue_SimpleQueue_put_nowait__doc__,
70"put_nowait($self, /, item)\n"
71"--\n"
72"\n"
73"Put an item into the queue without blocking.\n"
74"\n"
75"This is exactly equivalent to `put(item)` and is only provided\n"
76"for compatibility with the Queue class.");
77
78#define _QUEUE_SIMPLEQUEUE_PUT_NOWAIT_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +020079 {"put_nowait", (PyCFunction)(void(*)(void))_queue_SimpleQueue_put_nowait, METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_put_nowait__doc__},
Antoine Pitrou94e16962018-01-16 00:27:16 +010080
81static PyObject *
82_queue_SimpleQueue_put_nowait_impl(simplequeueobject *self, PyObject *item);
83
84static PyObject *
85_queue_SimpleQueue_put_nowait(simplequeueobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
86{
87 PyObject *return_value = NULL;
88 static const char * const _keywords[] = {"item", NULL};
89 static _PyArg_Parser _parser = {"O:put_nowait", _keywords, 0};
90 PyObject *item;
91
92 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
93 &item)) {
94 goto exit;
95 }
96 return_value = _queue_SimpleQueue_put_nowait_impl(self, item);
97
98exit:
99 return return_value;
100}
101
102PyDoc_STRVAR(_queue_SimpleQueue_get__doc__,
103"get($self, /, block=True, timeout=None)\n"
104"--\n"
105"\n"
106"Remove and return an item from the queue.\n"
107"\n"
108"If optional args \'block\' is true and \'timeout\' is None (the default),\n"
109"block if necessary until an item is available. If \'timeout\' is\n"
110"a non-negative number, it blocks at most \'timeout\' seconds and raises\n"
111"the Empty exception if no item was available within that time.\n"
112"Otherwise (\'block\' is false), return an item if one is immediately\n"
113"available, else raise the Empty exception (\'timeout\' is ignored\n"
114"in that case).");
115
116#define _QUEUE_SIMPLEQUEUE_GET_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200117 {"get", (PyCFunction)(void(*)(void))_queue_SimpleQueue_get, METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_get__doc__},
Antoine Pitrou94e16962018-01-16 00:27:16 +0100118
119static PyObject *
120_queue_SimpleQueue_get_impl(simplequeueobject *self, int block,
121 PyObject *timeout);
122
123static PyObject *
124_queue_SimpleQueue_get(simplequeueobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
125{
126 PyObject *return_value = NULL;
127 static const char * const _keywords[] = {"block", "timeout", NULL};
128 static _PyArg_Parser _parser = {"|pO:get", _keywords, 0};
129 int block = 1;
130 PyObject *timeout = Py_None;
131
132 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
133 &block, &timeout)) {
134 goto exit;
135 }
136 return_value = _queue_SimpleQueue_get_impl(self, block, timeout);
137
138exit:
139 return return_value;
140}
141
142PyDoc_STRVAR(_queue_SimpleQueue_get_nowait__doc__,
143"get_nowait($self, /)\n"
144"--\n"
145"\n"
146"Remove and return an item from the queue without blocking.\n"
147"\n"
148"Only get an item if one is immediately available. Otherwise\n"
149"raise the Empty exception.");
150
151#define _QUEUE_SIMPLEQUEUE_GET_NOWAIT_METHODDEF \
152 {"get_nowait", (PyCFunction)_queue_SimpleQueue_get_nowait, METH_NOARGS, _queue_SimpleQueue_get_nowait__doc__},
153
154static PyObject *
155_queue_SimpleQueue_get_nowait_impl(simplequeueobject *self);
156
157static PyObject *
158_queue_SimpleQueue_get_nowait(simplequeueobject *self, PyObject *Py_UNUSED(ignored))
159{
160 return _queue_SimpleQueue_get_nowait_impl(self);
161}
162
163PyDoc_STRVAR(_queue_SimpleQueue_empty__doc__,
164"empty($self, /)\n"
165"--\n"
166"\n"
167"Return True if the queue is empty, False otherwise (not reliable!).");
168
169#define _QUEUE_SIMPLEQUEUE_EMPTY_METHODDEF \
170 {"empty", (PyCFunction)_queue_SimpleQueue_empty, METH_NOARGS, _queue_SimpleQueue_empty__doc__},
171
172static int
173_queue_SimpleQueue_empty_impl(simplequeueobject *self);
174
175static PyObject *
176_queue_SimpleQueue_empty(simplequeueobject *self, PyObject *Py_UNUSED(ignored))
177{
178 PyObject *return_value = NULL;
179 int _return_value;
180
181 _return_value = _queue_SimpleQueue_empty_impl(self);
182 if ((_return_value == -1) && PyErr_Occurred()) {
183 goto exit;
184 }
185 return_value = PyBool_FromLong((long)_return_value);
186
187exit:
188 return return_value;
189}
190
191PyDoc_STRVAR(_queue_SimpleQueue_qsize__doc__,
192"qsize($self, /)\n"
193"--\n"
194"\n"
195"Return the approximate size of the queue (not reliable!).");
196
197#define _QUEUE_SIMPLEQUEUE_QSIZE_METHODDEF \
198 {"qsize", (PyCFunction)_queue_SimpleQueue_qsize, METH_NOARGS, _queue_SimpleQueue_qsize__doc__},
199
200static Py_ssize_t
201_queue_SimpleQueue_qsize_impl(simplequeueobject *self);
202
203static PyObject *
204_queue_SimpleQueue_qsize(simplequeueobject *self, PyObject *Py_UNUSED(ignored))
205{
206 PyObject *return_value = NULL;
207 Py_ssize_t _return_value;
208
209 _return_value = _queue_SimpleQueue_qsize_impl(self);
210 if ((_return_value == -1) && PyErr_Occurred()) {
211 goto exit;
212 }
213 return_value = PyLong_FromSsize_t(_return_value);
214
215exit:
216 return return_value;
217}
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200218/*[clinic end generated code: output=c12ce9050f153304 input=a9049054013a1b77]*/