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:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user