| 207 | |
| 208 | |
| 209 | void |
| 210 | taskset_fini( taskset_t *ts ) |
| 211 | { |
| 212 | if (ts == NULL) |
| 213 | { |
| 214 | return; |
| 215 | } |
| 216 | |
| 217 | int i; |
| 218 | if ( ts->task_thread_started ) { |
| 219 | /* |
| 220 | * Tell each thread to stop, and then cleanup. |
| 221 | */ |
| 222 | for ( i = 0; i < ts->thread_count; i++ ) |
| 223 | { |
| 224 | taskset_thread_t *thread = taskset_thread( ts, i ); |
| 225 | hb_lock( thread->lock ); |
| 226 | thread->begin = 1; |
| 227 | thread->stop = 1; |
| 228 | hb_cond_signal( thread->begin_cond ); |
| 229 | while ( !thread->complete ) { |
| 230 | hb_cond_wait( thread->complete_cond, thread->lock ); |
| 231 | } |
| 232 | hb_unlock( thread->lock ); |
| 233 | } |
| 234 | /* |
| 235 | * Clean up thread memory. |
| 236 | */ |
| 237 | for( i = 0; i < ts->thread_count; i++ ) |
| 238 | { |
| 239 | taskset_thread_t *thread = taskset_thread( ts, i ); |
| 240 | hb_thread_close( &thread->thread ); |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | /* |
| 245 | * Clean up taskset memory. |
| 246 | */ |
| 247 | for( i = 0; i < ts->thread_count; i++ ) |
| 248 | { |
| 249 | taskset_thread_t *thread = taskset_thread( ts, i ); |
| 250 | hb_lock_close( &thread->lock ); |
| 251 | hb_cond_close( &thread->begin_cond ); |
| 252 | hb_cond_close( &thread->complete_cond ); |
| 253 | } |
| 254 | |
| 255 | free( ts->task_threads ); |
| 256 | |
| 257 | if( ts->task_threads_args != NULL ) |
| 258 | free( ts->task_threads_args ); |
| 259 | } |
no test coverage detected