[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16122] branches/harmonic-skeleton/source/ blender/blenlib: Add a function to join thread by index in the thread list.

Martin Poirier theeth at yahoo.com
Fri Aug 15 01:48:56 CEST 2008


Revision: 16122
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16122
Author:   theeth
Date:     2008-08-15 01:48:52 +0200 (Fri, 15 Aug 2008)

Log Message:
-----------
Add a function to join thread by index in the thread list.

This can be safely merged in trunk, in case anyone needs something like that.

Modified Paths:
--------------
    branches/harmonic-skeleton/source/blender/blenlib/BLI_threads.h
    branches/harmonic-skeleton/source/blender/blenlib/intern/threads.c

Modified: branches/harmonic-skeleton/source/blender/blenlib/BLI_threads.h
===================================================================
--- branches/harmonic-skeleton/source/blender/blenlib/BLI_threads.h	2008-08-14 22:19:38 UTC (rev 16121)
+++ branches/harmonic-skeleton/source/blender/blenlib/BLI_threads.h	2008-08-14 23:48:52 UTC (rev 16122)
@@ -45,6 +45,7 @@
 int		BLI_available_thread_index(struct ListBase *threadbase);
 void	BLI_insert_thread	(struct ListBase *threadbase, void *callerdata);
 void	BLI_remove_thread	(struct ListBase *threadbase, void *callerdata);
+void	BLI_remove_thread_index(struct ListBase *threadbase, int index);
 void	BLI_end_threads		(struct ListBase *threadbase);
 
 void	BLI_lock_thread		(int type);

Modified: branches/harmonic-skeleton/source/blender/blenlib/intern/threads.c
===================================================================
--- branches/harmonic-skeleton/source/blender/blenlib/intern/threads.c	2008-08-14 22:19:38 UTC (rev 16121)
+++ branches/harmonic-skeleton/source/blender/blenlib/intern/threads.c	2008-08-14 23:48:52 UTC (rev 16122)
@@ -199,6 +199,21 @@
 	}
 }
 
+void BLI_remove_thread_index(ListBase *threadbase, int index)
+{
+	ThreadSlot *tslot;
+	int counter=0;
+	
+	for(tslot = threadbase->first; tslot; tslot = tslot->next, counter++) {
+		if (counter == index && tslot->avail == 0) {
+			tslot->callerdata = NULL;
+			pthread_join(tslot->pthread, NULL);
+			tslot->avail = 1;
+			break;
+		}
+	}
+}
+
 void BLI_end_threads(ListBase *threadbase)
 {
 	ThreadSlot *tslot;





More information about the Bf-blender-cvs mailing list