Detach worker threads upon creation
This commit is contained in:
parent
2a3fee2c3f
commit
ba685cc0ca
1 changed files with 3 additions and 2 deletions
5
visor.c
5
visor.c
|
@ -15,7 +15,6 @@
|
|||
int32_t thread_count;
|
||||
|
||||
struct threadInfo {
|
||||
pthread_t id;
|
||||
int32_t index; // unique number from 0 to thread_count-1
|
||||
bool drawing; // marks if we are currently drawing for a given thread
|
||||
bool complete; // marks if the drawing that it was supposed to
|
||||
|
@ -323,7 +322,9 @@ int main(int argc, char **argv)
|
|||
// we set this before the thread starts so it points to a valid
|
||||
// integer, if the thread fails to start, it will simply be
|
||||
// overwritten by the same value in the next run of the loop
|
||||
if (pthread_create(&threads[count].id, NULL, &writer_thread, &threads[count].index)) {
|
||||
pthread_t id;
|
||||
if (pthread_create(&id, NULL, &writer_thread, &threads[count].index)) {
|
||||
pthread_detach(id);
|
||||
fprintf(stderr, "Failed to create thread %d\n", i);
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue