diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2016-06-22 21:43:37 -0700 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2016-06-22 21:43:37 -0700 |
commit | 3cf9d22ba35ecf1511c093f6535279f4874a1918 (patch) | |
tree | 0521ef65fda49e88ce1b79457391f63b6ed2bf8d /src/choices.c | |
parent | 6519dd488987d4a672b99de03e558d126798630c (diff) |
Use threading when matching/scoring
Diffstat (limited to 'src/choices.c')
-rw-r--r-- | src/choices.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/choices.c b/src/choices.c index 6d841b1..02c551c 100644 --- a/src/choices.c +++ b/src/choices.c @@ -1,6 +1,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <pthread.h> #include "choices.h" #include "match.h" @@ -134,8 +135,6 @@ size_t choices_available(choices_t *c) { return c->available; } -#include <pthread.h> - struct worker { pthread_t thread_id; choices_t *choices; @@ -182,8 +181,7 @@ void choices_search(choices_t *c, const char *search) { workers[i].worker_count = worker_count; workers[i].worker_num = i; workers[i].results = malloc(c->size * sizeof(struct scored_result)); /* FIXME: This is overkill */ - int ret = pthread_create(&workers[i].thread_id, NULL, &choices_search_worker, &workers[i]); - if (ret != 0) { + if (pthread_create(&workers[i].thread_id, NULL, &choices_search_worker, &workers[i])) { perror("pthread_create"); exit(EXIT_FAILURE); } @@ -192,8 +190,7 @@ void choices_search(choices_t *c, const char *search) { for (int i = 0; i < worker_count; i++) { struct worker *w = &workers[i]; - int ret = pthread_join(w->thread_id, NULL); - if (ret != 0) { + if (pthread_join(w->thread_id, NULL)) { perror("pthread_join"); exit(EXIT_FAILURE); } |