Lines Matching refs:self
42 simplequeue_clear(simplequeueobject *self)
44 Py_CLEAR(self->lst);
49 simplequeue_dealloc(simplequeueobject *self)
51 PyTypeObject *tp = Py_TYPE(self);
53 PyObject_GC_UnTrack(self);
54 if (self->lock != NULL) {
56 if (self->locked > 0)
57 PyThread_release_lock(self->lock);
58 PyThread_free_lock(self->lock);
60 (void)simplequeue_clear(self);
61 if (self->weakreflist != NULL)
62 PyObject_ClearWeakRefs((PyObject *) self);
63 Py_TYPE(self)->tp_free(self);
68 simplequeue_traverse(simplequeueobject *self, visitproc visit, void *arg)
70 Py_VISIT(self->lst);
71 Py_VISIT(Py_TYPE(self));
86 simplequeueobject *self;
88 self = (simplequeueobject *) type->tp_alloc(type, 0);
89 if (self != NULL) {
90 self->weakreflist = NULL;
91 self->lst = PyList_New(0);
92 self->lock = PyThread_allocate_lock();
93 self->lst_pos = 0;
94 if (self->lock == NULL) {
95 Py_DECREF(self);
99 if (self->lst == NULL) {
100 Py_DECREF(self);
105 return (PyObject *) self;
122 _queue_SimpleQueue_put_impl(simplequeueobject *self, PyObject *item,
127 if (PyList_Append(self->lst, item) < 0)
129 if (self->locked) {
131 self->locked = 0;
132 PyThread_release_lock(self->lock);
150 _queue_SimpleQueue_put_nowait_impl(simplequeueobject *self, PyObject *item)
153 return _queue_SimpleQueue_put_impl(self, item, 0, Py_None);
157 simplequeue_pop_item(simplequeueobject *self)
162 n = PyList_GET_SIZE(self->lst);
163 assert(self->lst_pos < n);
165 item = PyList_GET_ITEM(self->lst, self->lst_pos);
167 PyList_SET_ITEM(self->lst, self->lst_pos, Py_None);
168 self->lst_pos += 1;
169 count = n - self->lst_pos;
170 if (self->lst_pos > count) {
172 if (PyList_SetSlice(self->lst, 0, self->lst_pos, NULL)) {
174 self->lst_pos -= 1;
175 PyList_SET_ITEM(self->lst, self->lst_pos, item);
178 self->lst_pos = 0;
204 _queue_SimpleQueue_get_impl(simplequeueobject *self, PyTypeObject *cls,
247 while (self->lst_pos == PyList_GET_SIZE(self->lst)) {
249 r = PyThread_acquire_lock_timed(self->lock, 0, 0);
252 r = PyThread_acquire_lock_timed(self->lock, microseconds, 1);
266 self->locked = 1;
277 assert(self->lst_pos < PyList_GET_SIZE(self->lst));
278 item = simplequeue_pop_item(self);
279 if (self->locked) {
280 PyThread_release_lock(self->lock);
281 self->locked = 0;
301 _queue_SimpleQueue_get_nowait_impl(simplequeueobject *self,
305 return _queue_SimpleQueue_get_impl(self, cls, 0, Py_None);
315 _queue_SimpleQueue_empty_impl(simplequeueobject *self)
318 return self->lst_pos == PyList_GET_SIZE(self->lst);
328 _queue_SimpleQueue_qsize_impl(simplequeueobject *self)
331 return PyList_GET_SIZE(self->lst) - self->lst_pos;