[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16141] branches/harmonic-skeleton/source/ blender/src/autoarmature.c: Use ThreadedWorker for dispatch

Martin Poirier theeth at yahoo.com
Sun Aug 17 00:48:43 CEST 2008


Revision: 16141
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16141
Author:   theeth
Date:     2008-08-17 00:48:43 +0200 (Sun, 17 Aug 2008)

Log Message:
-----------
Use ThreadedWorker for dispatch

Modified Paths:
--------------
    branches/harmonic-skeleton/source/blender/src/autoarmature.c

Modified: branches/harmonic-skeleton/source/blender/src/autoarmature.c
===================================================================
--- branches/harmonic-skeleton/source/blender/src/autoarmature.c	2008-08-16 22:47:33 UTC (rev 16140)
+++ branches/harmonic-skeleton/source/blender/src/autoarmature.c	2008-08-16 22:48:43 UTC (rev 16141)
@@ -96,8 +96,7 @@
 	ReebGraph *link_mesh;
 	
 	ListBase controls;
-	ListBase threads;
-	char threads_used[NB_THREADS];
+	struct ThreadedWorker *worker;
 	
 	GHash *bones_map;
 	
@@ -158,7 +157,6 @@
 typedef struct RetargetParam {
 	RigGraph	*rigg;
 	RigArc		*iarc;
-	int			 index;
 } RetargetParam;
 
 typedef enum 
@@ -263,7 +261,9 @@
 	rg->free_arc = RIG_freeRigArc;
 	rg->free_node = NULL;
 	
-	BLI_init_threads(&rg->threads, exec_retargetArctoArc, NB_THREADS); /* fix number of threads */
+#ifdef USE_THREADS
+	rg->worker = BLI_create_worker(exec_retargetArctoArc, NB_THREADS, 20); /* fix number of threads */
+#endif
 	
 	return rg;
 }
@@ -1592,38 +1592,11 @@
 {
 #ifdef USE_THREADS
 	RetargetParam *p = MEM_callocN(sizeof(RetargetParam), "RetargetParam");
-	int index;
 	
 	p->rigg = rigg;
 	p->iarc = iarc;
 	
-	/* fix that with proper flagging */
-	if (BLI_available_threads(&rigg->threads) == 0)
-	{
-		index = NB_THREADS;
-		while(index == NB_THREADS)
-		{
-			PIL_sleep_ms(20);
-			
-			for (index = 0; index < NB_THREADS; index++)
-			{
-				if (rigg->threads_used[index] == 0)
-				{
-					BLI_remove_thread_index(&rigg->threads, index);
-					break;
-				}
-			}
-		}
-	}
-	else
-	{
-		index = BLI_available_thread_index(&rigg->threads);
-	}
-	
-	p->index = index;
-	rigg->threads_used[index] = 1;
-	BLI_insert_thread(&rigg->threads, p);
-	
+	BLI_insert_work(rigg->worker, p);
 #else
 	RetargetParam p;
 	p.rigg = rigg;
@@ -1670,8 +1643,7 @@
 	}
 
 #ifdef USE_THREADS
-	MEM_freeN(param);
-	rigg->threads_used[p->index] = 0;
+	MEM_freeN(p);
 #endif
 	
 	return NULL;
@@ -1860,7 +1832,9 @@
 
 	retargetSubgraph(rigg, NULL, inode);
 	
-	BLI_end_threads(&rigg->threads);
+#ifdef USE_THREADS
+	BLI_destroy_worker(rigg->worker);
+#endif
 }
 
 void BIF_retargetArmature()





More information about the Bf-blender-cvs mailing list