Author: DerekRhodes
Date: 2008-03-06 14:22:58 -0500 (Thu, 06 Mar 2008)
New Revision: 1069

Modified:
   trunk/pysoy/src/_datatypes/FaceList.pxi
   trunk/pysoy/src/_datatypes/MaterialList.pxi
   trunk/pysoy/src/_datatypes/VertexList.pxi
Log:
Ticket #901
changed erroneous children._stepLocks to direct py.PyThread locks


Modified: trunk/pysoy/src/_datatypes/FaceList.pxi
===================================================================
--- trunk/pysoy/src/_datatypes/FaceList.pxi     2008-03-06 18:28:09 UTC (rev 
1068)
+++ trunk/pysoy/src/_datatypes/FaceList.pxi     2008-03-06 19:22:58 UTC (rev 
1069)
@@ -51,21 +51,18 @@
     # instance of every face in every mesh - that'd eat way too much memory.
     #
     _found = 0
-    ##self._children.lock()
-    self._children._stepLock()
+    py.PyThread_acquire_lock((<soy.meshes.Mesh> self._mesh)._mutex, 1)
     if _index < 0 :    
       _index = self._arraySize + _index
     if _index < 0 or _index >= self._arraySize :
-      ##self._children.unlock()
-      self._children._stepUnlock()
+      py.PyThread_release_lock((<soy.meshes.Mesh> self._mesh)._mutex)
       raise IndexError('face index out of range')
     for i from 0 <= i < self._children._current :
       if (<soy.atoms.Face> self._children._list[i])._index == _index :
         _face = <soy.atoms.Face> self._children._list[i]
         _found = 1
         break
-    ##self._children.unlock()
-    self._children._stepUnlock()
+    py.PyThread_release_lock((<soy.meshes.Mesh> self._mesh)._mutex)
     if not _found :
       _face = soy.atoms.Face(mesh = <soy.meshes.Mesh> self._mesh,
                              index= _index)
@@ -89,16 +86,14 @@
 
 
   cdef void _createBuffer(self) :
-    ##self._children.lock()
-    self._children._stepLock()
+    py.PyThread_acquire_lock((<soy.meshes.Mesh> self._mesh)._mutex, 1)
     self._bufferAlloc = self._arrayAlloc
     self._updateRange.length = 0
     gl.glGenBuffersARB(1, &self._buffer)
     gl.glBindBufferARB(gl.GL_ELEMENT_ARRAY_BUFFER_ARB, self._buffer)
     gl.glBufferDataARB(gl.GL_ELEMENT_ARRAY_BUFFER_ARB, 6*self._bufferAlloc,
                        self._array, gl.GL_STATIC_DRAW_ARB)
-    ##self._children.unlock()
-    self._children._stepUnlock()
+    py.PyThread_release_lock((<soy.meshes.Mesh> self._mesh)._mutex)
 
 
   cdef void _flagUpdated(self, int _offset, int _length) :
@@ -125,8 +120,8 @@
     if self._updateRange.length == 0 :
       return
     # If in the process of writing, wait until next cycle to send
-    if not self._children.trylock() :
-      return
+    #if not self._children.trylock() :         #future optimization happens 
here
+    #  return                                  #future optimization happens 
here
     # If the range to be updated is larger than the existing buffer
     if self._updateRange.offset+self._updateRange.length > self._bufferAlloc :
       self._bufferAlloc = self._arrayAlloc
@@ -138,8 +133,7 @@
                             6 * (self._updateRange.length+1),
                             &self._array[self._updateRange.offset])
     self._updateRange.length = 0
-    ##self._children.unlock()
-    self._children._stepUnlock()
+    py.PyThread_release_lock((<soy.meshes.Mesh> self._mesh)._mutex)
 
 
   cdef void _allocArray(self, int num) :

Modified: trunk/pysoy/src/_datatypes/MaterialList.pxi
===================================================================
--- trunk/pysoy/src/_datatypes/MaterialList.pxi 2008-03-06 18:28:09 UTC (rev 
1068)
+++ trunk/pysoy/src/_datatypes/MaterialList.pxi 2008-03-06 19:22:58 UTC (rev 
1069)
@@ -37,12 +37,11 @@
 
   def __dealloc__(self) :
     cdef int i
-    ##self._children.lock()
-    self._children._stepLock()
+    py.PyThread_acquire_lock((<soy.meshes.Mesh> self._mesh)._mutex, 1)
     for i from 0 <= i < self._children._current :
       py.Py_DECREF(<object> self._children._list[i])
-    ##self._children.unlock()
-    self._children._stepUnlock()
+    py.PyThread_release_lock((<soy.meshes.Mesh> self._mesh)._mutex)
+    
 
 
   def __len__(self) :
@@ -54,10 +53,10 @@
     cdef object l
     cdef soy.meshes.Mesh _mesh
     l = []
-    self._children._stepLock()
+    py.PyThread_acquire_lock((<soy.meshes.Mesh> self._mesh)._mutex, 1)
     for i from 0 <= i < self._children._current :
       l.append(<soy.materials.Material> self._children._list[i])
-    self._children._stepUnlock()
+    py.PyThread_release_lock((<soy.meshes.Mesh> self._mesh)._mutex)
     return str(l)
 
 
@@ -67,16 +66,14 @@
 
   def __getitem__(self, _index) :
     cdef soy.materials.Material _mat
-    ##self._children.lock()
-    self._children._stepLock()    
+    py.PyThread_acquire_lock((<soy.meshes.Mesh> self._mesh)._mutex, 1)    
     if _index < 0 :
       _index = self._children._current + _index
     if _index < 0 or _index >= self._children._current :
-      self._children._stepUnlock()
+      py.PyThread_release_lock((<soy.meshes.Mesh> self._mesh)._mutex)
       raise IndexError('material index out of range')
     _mat = <soy.materials.Material> self._children._list[_index]
-    ##self._children.unlock()
-    self._children._stepUnlock()
+    py.PyThread_release_lock((<soy.meshes.Mesh> self._mesh)._mutex)
     return _mat
 
 
@@ -89,24 +86,20 @@
       _mesh._verts._calculateTSLV(body)
 
     _mesh._verts._coreRenderArrayBumpPass()
-    ##self._children.lock()
-    self._children._stepLock()
+    py.PyThread_acquire_lock((<soy.meshes.Mesh> self._mesh)._mutex, 1)
     for i from 0 <= i < self._children._current :
       (<soy.materials.Material> self._children._list[i])._coreBind()
       _mesh._faces._coreRenderArray(self._ranges[i].offset, 
self._ranges[i].length)
       (<soy.materials.Material> self._children._list[i])._coreUnBind()
-    ##self._children.unlock()
-    self._children._stepUnlock()
+    py.PyThread_release_lock((<soy.meshes.Mesh> self._mesh)._mutex)
 
     _mesh._verts._coreRenderArray()
-    ##self._children.lock()
-    self._children._stepLock()
+    py.PyThread_acquire_lock((<soy.meshes.Mesh> self._mesh)._mutex, 1)
     for i from 0 <= i < self._children._current :
       (<soy.materials.Material> self._children._list[i])._coreBind()
       _mesh._faces._coreRenderArray(self._ranges[i].offset, 
self._ranges[i].length)
       (<soy.materials.Material> self._children._list[i])._coreUnBind()
-    ##self._children.unlock()
-    self._children._stepUnlock()
+    py.PyThread_release_lock((<soy.meshes.Mesh> self._mesh)._mutex)
 
 
   cdef void _coreRenderBuffer(self, void* body) :
@@ -126,25 +119,21 @@
 
     _mesh._verts._coreRenderBufferBumpPass()
 
-    ##self._children.lock()
-    self._children._stepLock()
+    py.PyThread_acquire_lock((<soy.meshes.Mesh> self._mesh)._mutex, 1)
     for i from 0 <= i < self._children._current :
         if (<soy.materials.Material> self._children._list[i])._has_bumpmap():
           (<soy.materials.Material> 
self._children._list[i])._coreBindBumpPass()
           _mesh._faces._coreRenderBuffer(self._ranges[i].offset, 
self._ranges[i].length)
           (<soy.materials.Material> 
self._children._list[i])._coreUnBindBumpPass()
-    ##self._children.unlock()
-    self._children._stepUnlock()
+    py.PyThread_release_lock((<soy.meshes.Mesh> self._mesh)._mutex)
 
     _mesh._verts._coreRenderBuffer()
-    ##self._children.lock()
-    self._children._stepLock()
+    py.PyThread_acquire_lock((<soy.meshes.Mesh> self._mesh)._mutex, 1)
     for i from 0 <= i < self._children._current :
       (<soy.materials.Material> self._children._list[i])._coreBind()
       _mesh._faces._coreRenderBuffer(self._ranges[i].offset, 
self._ranges[i].length)
       (<soy.materials.Material> self._children._list[i])._coreUnBind()
-    ##self._children.unlock()
-    self._children._stepUnlock()      
+    py.PyThread_release_lock((<soy.meshes.Mesh> self._mesh)._mutex)      
 
 
   cdef void _allocRanges(self, int num) :

Modified: trunk/pysoy/src/_datatypes/VertexList.pxi
===================================================================
--- trunk/pysoy/src/_datatypes/VertexList.pxi   2008-03-06 18:28:09 UTC (rev 
1068)
+++ trunk/pysoy/src/_datatypes/VertexList.pxi   2008-03-06 19:22:58 UTC (rev 
1069)
@@ -32,8 +32,8 @@
     self._mesh = <void*> mesh
     self._children = soy._internals.Children()
     self._bufferAlloc = 0
+    self._mutex = mesh._mutex
 
-
   def __len__(self) :
     return self._arraySize
 
@@ -43,7 +43,6 @@
     cdef object l
     cdef soy.meshes.Mesh _mesh
     l = []
-    #self._children.lock()
     self._children._startIter()
     for i from 0 <= i < self._arraySize :
       l.append({'position':(self._array[i].px,
@@ -55,8 +54,7 @@
                 'texcoord':(self._array[i].tx,
                             self._array[i].ty,
                             self._array[i].tz)})
-    #self._children.unlock()
-    self._children.iterDone()
+    self._children._iterDone()
     return str(l)
 
 
@@ -74,21 +72,18 @@
     # instance of every vertex in every mesh - that'd eat way too much memory.
     #
     _found = 0
-    #self._children.lock()
-    self._children._stepLock()
+    py.PyThread_acquire_lock((<soy.meshes.Mesh> self._mesh)._mutex, 1)
     if _index < 0 :
       _index = self._arraySize + _index
     if _index < 0 or _index >= self._arraySize :
-      #self._children.unlock()
-      self._children._stepUnlock()
+      py.PyThread_release_lock((<soy.meshes.Mesh> self._mesh)._mutex)
       raise IndexError('vertex index out of range')
     for i from 0 <= i < self._children._current :
       if (<soy.atoms.Vertex> self._children._list[i])._index == _index :
         _vert = <soy.atoms.Vertex> self._children._list[i]
         _found = 1
         break
-    #self._children.unlock()
-    self._children._stepUnlock()
+    py.PyThread_release_lock((<soy.meshes.Mesh> self._mesh)._mutex)
     if not _found :
       _vert = soy.atoms.Vertex(mesh = <soy.meshes.Mesh> self._mesh, 
                                index= _index)
@@ -161,8 +156,9 @@
     if self._updateRange.offset == -1 :
       return
     # If in the process of writing, wait until next cycle to send
-    if not self._children.trylock() :
-      return
+    #if not self._children.trylock() :         #future optimization happens 
here
+    #  return                                  #future optimization happens 
here
+    
     # If the range to be updated is larger than the existing buffer
     if self._updateRange.offset+self._updateRange.length > self._bufferAlloc :
       self._bufferAlloc = self._arrayAlloc
@@ -175,7 +171,7 @@
                             &self._array[self._updateRange.offset])
     self._updateRange.offset = -1
     self._updateRange.length = 0
-    self._children._stepUnlock()
+    #py.PyThread_release_lock(self._mutex)     #future optimization happens 
here
 
 
   cdef void _allocArray(self, int _num) :
@@ -281,6 +277,3 @@
     #  self._tslvArray[3*_i + 0] = 0
     #  self._tslvArray[3*_i + 1] = 0
     #  self._tslvArray[3*_i + 2] = 1
-
-# Cleaned most,
-# Still have to deal with the _children.trylock(), line# 164

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

Reply via email to