Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

implemented api for TileProvider thread query and manipulation; closes

  • Loading branch information...
commit 4b9c4ef9fe5d21ed0b527a819d9cd1f3c925ff03 1 parent 6768144
@bekaus bekaus authored
Showing with 39 additions and 6 deletions.
  1. +2 −1  tests/tiling_tests.py
  2. +37 −5 volumina/tiling.py
View
3  tests/tiling_tests.py
@@ -85,7 +85,8 @@ def testSetAllLayersInvisible( self ):
finally:
tp.notifyThreadsToStop()
-
+ tp.joinThreads()
+
if __name__=='__main__':
View
42 volumina/tiling.py
@@ -392,6 +392,16 @@ def requestRefresh( self, rectF ):
stack_id = self._current_stack_id
self._refreshTile( stack_id, tile_no )
+ def join( self ):
+ '''Wait until all refresh request are processed.
+
+ Blocks until no refresh request pending anymore and all rendering
+ finished.
+
+ '''
+ return self._dirtyLayerQueue.join()
+
+
def notifyThreadsToStop( self ):
'''Signals render threads to stop.
@@ -402,14 +412,36 @@ def notifyThreadsToStop( self ):
'''
self._keepRendering = False
- def join( self ):
- '''Wait until all refresh request are processed.
+ def threadsAreNotifiedToStop( self ):
+ '''Check if NotifyThreadsToStop() was called at least once.'''
+ return not self._keepRendering
- Blocks until no refresh request pending anymore and all rendering
- finished.
+ def joinThreads( self, timeout=None ):
+ '''Wait until all threads terminated.
+
+ Without calling notifyThreadsToStop, threads will never
+ terminate.
+ Arguments:
+ timeout -- timeout in seconds as a floating point number
+
'''
- return self._dirtyLayerQueue.join()
+ for thread in self._dirtyLayerThreads:
+ thread.join( timeout )
+
+ def aliveThreads( self ):
+ '''Return a map of thread identifiers and their alive status.
+
+ All threads are alive until notifyThreadsToStop() is
+ called. After that, they start dying. Call joinThreads() to wait
+ for the last thread to die.
+
+ '''
+ at = {}
+ for thread in self._dirtyLayerThreads:
+ if thread.ident:
+ at[thread.ident] = thread.isAlive()
+ return at
def _dirtyLayersWorker( self ):
while self._keepRendering:
Please sign in to comment.
Something went wrong with that request. Please try again.