Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
bd4ae96b
Commit
bd4ae96b
authored
Aug 01, 2017
by
Peter W. Draper
Browse files
Merge branch 'master' into sort_arrays
parents
27f89d7e
4098909c
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/threadpool.c
View file @
bd4ae96b
...
...
@@ -314,21 +314,23 @@ void threadpool_reset_log(struct threadpool *tp) {
* @brief Frees up the memory allocated for this #threadpool.
*/
void
threadpool_clean
(
struct
threadpool
*
tp
)
{
/* Destroy the runner threads by calling them with a NULL mapper function
and waiting for all the threads to terminate. This ensures that no thread
is still waiting at a barrier. */
tp
->
map_function
=
NULL
;
pthread_barrier_wait
(
&
tp
->
run_barrier
);
for
(
int
k
=
0
;
k
<
tp
->
num_threads
-
1
;
k
++
)
{
void
*
retval
;
pthread_join
(
tp
->
threads
[
k
],
&
retval
);
}
/* Release the barriers. */
if
(
pthread_barrier_destroy
(
&
tp
->
wait_barrier
)
!=
0
||
pthread_barrier_destroy
(
&
tp
->
run_barrier
)
!=
0
)
error
(
"Failed to destroy threadpool barriers."
);
if
(
tp
->
num_threads
>
1
)
{
/* Destroy the runner threads by calling them with a NULL mapper function
* and waiting for all the threads to terminate. This ensures that no
* thread is still waiting at a barrier. */
tp
->
map_function
=
NULL
;
pthread_barrier_wait
(
&
tp
->
run_barrier
);
for
(
int
k
=
0
;
k
<
tp
->
num_threads
-
1
;
k
++
)
{
void
*
retval
;
pthread_join
(
tp
->
threads
[
k
],
&
retval
);
}
/* Release the barriers. */
if
(
pthread_barrier_destroy
(
&
tp
->
wait_barrier
)
!=
0
||
pthread_barrier_destroy
(
&
tp
->
run_barrier
)
!=
0
)
error
(
"Failed to destroy threadpool barriers."
);
}
/* Clean up memory. */
free
(
tp
->
threads
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment