Author: ArcRiley Date: 2008-03-18 18:16:45 -0400 (Tue, 18 Mar 2008) New Revision: 1170
Modified: trunk/pysoy/src/_internals/Children.pxi trunk/pysoy/src/_internals/soy._internals.pxd Log: No Ticket : * renamed internal function _index to _offset * created new external _index function with proper locking Modified: trunk/pysoy/src/_internals/Children.pxi =================================================================== --- trunk/pysoy/src/_internals/Children.pxi 2008-03-18 22:03:08 UTC (rev 1169) +++ trunk/pysoy/src/_internals/Children.pxi 2008-03-18 22:16:45 UTC (rev 1170) @@ -62,7 +62,7 @@ # Internal C functions # - cdef int _index(self, void* _child) : + cdef int _offset(self, void* _child) : cdef int _i for _i from 0 <= _i < self._current : if self._list[_i] == _child : @@ -98,11 +98,11 @@ cdef void _bottom(self, void* _child) : - cdef int _index + cdef int _offset py.PyThread_acquire_lock(self._lockMain, 1) - _index = self._index(_child) - if _index > 0 : - self._swap(_index, 0) + _offset = self._offset(_child) + if _offset > 0 : + self._swap(_offset, 0) py.PyThread_release_lock(self._lockMain) @@ -115,6 +115,14 @@ py.PyThread_release_lock(self._lockMain) + cdef int _index(self, void* _child) : + cdef int _i + self._iterStart() + _i = self._offset(_child) + self._iterDone() + return _i + + cdef void _iterDone(self) : py.PyThread_acquire_lock(self._lockIter, 1) self._iters = self._iters - 1 @@ -130,47 +138,47 @@ cdef void _lower(self, void* _child) : - cdef int _index + cdef int _offset py.PyThread_acquire_lock(self._lockMain, 1) - _index = self._index(_child) - if _index > 0 : - self._swap(_index, _index - 1) + _offset = self._offset(_child) + if _offset > 0 : + self._swap(_offset, _offset - 1) cdef void _raise(self, void* _child) : - cdef int _index + cdef int _offset py.PyThread_acquire_lock(self._lockMain, 1) - _index = self._index(_child) - if _index == -1 : + _offset = self._offset(_child) + if _offset == -1 : return - if _index < self._current-1 : - self._swap(_index, _index + 1) + if _offset < self._current-1 : + self._swap(_offset, _offset + 1) py.PyThread_release_lock(self._lockMain) cdef void _remove(self, void* _child) : - cdef int _i, _index + cdef int _i, _offset py.PyThread_acquire_lock(self._lockMain, 1) # # Wait until all iterations are complete while self._iters != 0 : _sleep(1) - _index = self._index(_child) - if _index == -1 : + _offset = self._offset(_child) + if _offset == -1 : py.PyThread_release_lock(self._lockMain) return - for _i from _index <= _i < (self._current - 1) : + for _i from _offset <= _i < (self._current - 1) : self._list[_i] = self._list[_i + 1] self._current = self._current - 1 py.PyThread_release_lock(self._lockMain) cdef void _top(self, void* _child) : - cdef int _index + cdef int _offset py.PyThread_acquire_lock(self._lockMain, 1) - _index = self._index(_child) - if _index == -1 : + _offset = self._offset(_child) + if _offset == -1 : return - if _index < self._current - 1 : - self._swap(_index, self._current - 1) + if _offset < self._current - 1 : + self._swap(_offset, self._current - 1) py.PyThread_release_lock(self._lockMain) Modified: trunk/pysoy/src/_internals/soy._internals.pxd =================================================================== --- trunk/pysoy/src/_internals/soy._internals.pxd 2008-03-18 22:03:08 UTC (rev 1169) +++ trunk/pysoy/src/_internals/soy._internals.pxd 2008-03-18 22:16:45 UTC (rev 1170) @@ -36,12 +36,13 @@ cdef void* _lockMain cdef void* _lockIter # Internal C functions - cdef int _index ( self, void* ) + cdef int _offset ( self, void* ) cdef void _swap ( self, int, int ) # External C functions cdef void _append ( self, void* ) cdef void _bottom ( self, void* ) cdef void _empty ( self ) + cdef int _index ( self, void* ) cdef void _iterDone ( self ) cdef void _iterStart ( self ) cdef void _lower ( self, void* ) _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn