• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4 
5 PyDoc_STRVAR(simplequeue_new__doc__,
6 "SimpleQueue()\n"
7 "--\n"
8 "\n"
9 "Simple, unbounded, reentrant FIFO queue.");
10 
11 static PyObject *
12 simplequeue_new_impl(PyTypeObject *type);
13 
14 static PyObject *
simplequeue_new(PyTypeObject * type,PyObject * args,PyObject * kwargs)15 simplequeue_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 
29 exit:
30     return return_value;
31 }
32 
33 PyDoc_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    \
43     {"put", (PyCFunction)_queue_SimpleQueue_put, METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_put__doc__},
44 
45 static PyObject *
46 _queue_SimpleQueue_put_impl(simplequeueobject *self, PyObject *item,
47                             int block, PyObject *timeout);
48 
49 static PyObject *
_queue_SimpleQueue_put(simplequeueobject * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)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 
65 exit:
66     return return_value;
67 }
68 
69 PyDoc_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    \
79     {"put_nowait", (PyCFunction)_queue_SimpleQueue_put_nowait, METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_put_nowait__doc__},
80 
81 static PyObject *
82 _queue_SimpleQueue_put_nowait_impl(simplequeueobject *self, PyObject *item);
83 
84 static PyObject *
_queue_SimpleQueue_put_nowait(simplequeueobject * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)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 
98 exit:
99     return return_value;
100 }
101 
102 PyDoc_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    \
117     {"get", (PyCFunction)_queue_SimpleQueue_get, METH_FASTCALL|METH_KEYWORDS, _queue_SimpleQueue_get__doc__},
118 
119 static PyObject *
120 _queue_SimpleQueue_get_impl(simplequeueobject *self, int block,
121                             PyObject *timeout);
122 
123 static PyObject *
_queue_SimpleQueue_get(simplequeueobject * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)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 
138 exit:
139     return return_value;
140 }
141 
142 PyDoc_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 
154 static PyObject *
155 _queue_SimpleQueue_get_nowait_impl(simplequeueobject *self);
156 
157 static PyObject *
_queue_SimpleQueue_get_nowait(simplequeueobject * self,PyObject * Py_UNUSED (ignored))158 _queue_SimpleQueue_get_nowait(simplequeueobject *self, PyObject *Py_UNUSED(ignored))
159 {
160     return _queue_SimpleQueue_get_nowait_impl(self);
161 }
162 
163 PyDoc_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 
172 static int
173 _queue_SimpleQueue_empty_impl(simplequeueobject *self);
174 
175 static PyObject *
_queue_SimpleQueue_empty(simplequeueobject * self,PyObject * Py_UNUSED (ignored))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 
187 exit:
188     return return_value;
189 }
190 
191 PyDoc_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 
200 static Py_ssize_t
201 _queue_SimpleQueue_qsize_impl(simplequeueobject *self);
202 
203 static PyObject *
_queue_SimpleQueue_qsize(simplequeueobject * self,PyObject * Py_UNUSED (ignored))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 
215 exit:
216     return return_value;
217 }
218 /*[clinic end generated code: output=8badc3bb85263689 input=a9049054013a1b77]*/
219