Author: ColinHahn
Date: 2008-03-18 18:58:45 -0400 (Tue, 18 Mar 2008)
New Revision: 1172

Modified:
   trunk/pysoy/src/_internals/Children.pxi
Log:
Changed position-editing calls to respect the iterStart/iterDone locking.


Modified: trunk/pysoy/src/_internals/Children.pxi
===================================================================
--- trunk/pysoy/src/_internals/Children.pxi     2008-03-18 22:53:04 UTC (rev 
1171)
+++ trunk/pysoy/src/_internals/Children.pxi     2008-03-18 22:58:45 UTC (rev 
1172)
@@ -97,17 +97,41 @@
     py.PyThread_release_lock(self._lockMain)
 
 
+  cdef void _top(self, void* _child) :
+    cdef int _offset
+    py.PyThread_acquire_lock(self._lockMain, 1)
+    # Wait until all iterations are complete
+    while self._iters != 0 :
+      _sleep(1)
+    _offset = self._offset(_child)
+    if _offset == -1 :
+      return  
+    if _offset < self._current - 1 :
+      # Swap the item with the one at the top of the list -
+      # Probably not the expected semantics!
+      self._swap(_offset, self._current - 1)
+    py.PyThread_release_lock(self._lockMain)
+
+
   cdef void _bottom(self, void* _child) :
     cdef int _offset
     py.PyThread_acquire_lock(self._lockMain, 1)
+    # Wait until all iterations are complete
+    while self._iters != 0 :
+      _sleep(1)
     _offset = self._offset(_child)
     if _offset > 0 :
+      # Swap the item with the one at the bottom of the list -
+      # Probably not the expected semantics!
       self._swap(_offset, 0)
     py.PyThread_release_lock(self._lockMain)
 
 
   cdef void _empty(self) :
     py.PyThread_acquire_lock(self._lockMain, 1)
+    # Wait until all iterations are complete
+    while self._iters != 0 :
+      _sleep(1)
     py.PyMem_Free(self._list)
     self._size = 1
     self._current = 0
@@ -140,14 +164,21 @@
   cdef void _lower(self, void* _child) :
     cdef int _offset
     py.PyThread_acquire_lock(self._lockMain, 1)
+    # Wait until all iterations are complete
+    while self._iters != 0 :
+      _sleep(1)
     _offset = self._offset(_child)
     if _offset > 0 :
       self._swap(_offset, _offset - 1)
+    py.PyThread_release_lock(self._lockMain)
 
 
   cdef void _raise(self, void* _child) :
     cdef int _offset
     py.PyThread_acquire_lock(self._lockMain, 1)
+    # Wait until all iterations are complete
+    while self._iters != 0 :
+      _sleep(1)
     _offset = self._offset(_child)
     if _offset == -1 :
       return  
@@ -172,13 +203,3 @@
     self._current = self._current - 1
     py.PyThread_release_lock(self._lockMain)
 
-
-  cdef void _top(self, void* _child) :
-    cdef int _offset
-    py.PyThread_acquire_lock(self._lockMain, 1)
-    _offset = self._offset(_child)
-    if _offset == -1 :
-      return  
-    if _offset < self._current - 1 :
-      self._swap(_offset, self._current - 1)
-    py.PyThread_release_lock(self._lockMain)

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to