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.
This commit is contained in:
Martin Poirier
2008-08-14 23:48:52 +00:00
parent db42038bcf
commit feb5e3a688
2 changed files with 16 additions and 0 deletions

View File

@@ -45,6 +45,7 @@ int BLI_available_threads(struct ListBase *threadbase);
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);

View File

@@ -199,6 +199,21 @@ void BLI_remove_thread(ListBase *threadbase, void *callerdata)
}
}
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;