* Block until all currently executing tasks for this taskqueue * complete. Tasks that begin execution during the execution * of this function are ignored. */
| 399 | * of this function are ignored. |
| 400 | */ |
| 401 | static int |
| 402 | taskqueue_drain_tq_active(struct taskqueue *queue) |
| 403 | { |
| 404 | struct taskqueue_busy *tb; |
| 405 | u_int seq; |
| 406 | |
| 407 | if (LIST_EMPTY(&queue->tq_active)) |
| 408 | return (0); |
| 409 | |
| 410 | /* Block taskq_terminate().*/ |
| 411 | queue->tq_callouts++; |
| 412 | |
| 413 | /* Wait for any active task with sequence from the past. */ |
| 414 | seq = queue->tq_seq; |
| 415 | restart: |
| 416 | LIST_FOREACH(tb, &queue->tq_active, tb_link) { |
| 417 | if ((int)(tb->tb_seq - seq) <= 0) { |
| 418 | TQ_SLEEP(queue, tb->tb_running, "tq_adrain"); |
| 419 | goto restart; |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | /* Release taskqueue_terminate(). */ |
| 424 | queue->tq_callouts--; |
| 425 | if ((queue->tq_flags & TQ_FLAGS_ACTIVE) == 0) |
| 426 | wakeup_one(queue->tq_threads); |
| 427 | return (1); |
| 428 | } |
| 429 | |
| 430 | void |
| 431 | taskqueue_block(struct taskqueue *queue) |
no test coverage detected