mirror of https://github.com/ecmwf/eccodes.git
Pthread examples
This commit is contained in:
parent
bd289bc8fd
commit
d36ea27f48
|
@ -45,7 +45,7 @@ static void* process_bufr(void* arg)
|
|||
int main(int argc, char** argv)
|
||||
{
|
||||
pthread_t thread1, thread2;
|
||||
int error = 0, err = 0;
|
||||
int err = 0;
|
||||
FILE* fin = 0;
|
||||
codes_handle* h1 = 0;
|
||||
codes_handle* h2 = 0;
|
||||
|
@ -56,11 +56,11 @@ int main(int argc, char** argv)
|
|||
h2 = codes_handle_new_from_file(NULL, fin, PRODUCT_BUFR, &err); assert(h2);
|
||||
fclose(fin);
|
||||
|
||||
error = pthread_create(&thread1, NULL, process_bufr, (void *)h1);
|
||||
assert(!error);
|
||||
err = pthread_create(&thread1, NULL, process_bufr, (void *)h1);
|
||||
assert(!err);
|
||||
|
||||
error = pthread_create(&thread2, NULL, process_bufr, (void *)h2);
|
||||
assert(!error);
|
||||
err = pthread_create(&thread2, NULL, process_bufr, (void *)h2);
|
||||
assert(!err);
|
||||
|
||||
pthread_join(thread1, NULL);
|
||||
pthread_join(thread2, NULL);
|
||||
|
|
|
@ -67,6 +67,9 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
pthread_exit(NULL);
|
||||
for (i=0; i<NUM_THREADS; ++i) {
|
||||
pthread_join(threads[i], NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue