| 874 | */ |
| 875 | |
| 876 | static void wait_on_queue(KEYCACHE_WQUEUE *wqueue, |
| 877 | mysql_mutex_t *mutex) |
| 878 | { |
| 879 | struct st_my_thread_var *last; |
| 880 | struct st_my_thread_var *thread= my_thread_var; |
| 881 | |
| 882 | /* Add to queue. */ |
| 883 | DBUG_ASSERT(!thread->next); |
| 884 | DBUG_ASSERT(!thread->prev); /* Not required, but must be true anyway. */ |
| 885 | if (! (last= wqueue->last_thread)) |
| 886 | thread->next= thread; |
| 887 | else |
| 888 | { |
| 889 | thread->next= last->next; |
| 890 | last->next= thread; |
| 891 | } |
| 892 | wqueue->last_thread= thread; |
| 893 | |
| 894 | /* |
| 895 | Wait until thread is removed from queue by the signalling thread. |
| 896 | The loop protects against stray signals. |
| 897 | */ |
| 898 | do |
| 899 | { |
| 900 | KEYCACHE_DBUG_PRINT("wait", ("suspend thread %ld", thread->id)); |
| 901 | keycache_pthread_cond_wait(&thread->suspend, mutex); |
| 902 | } |
| 903 | while (thread->next); |
| 904 | } |
| 905 | |
| 906 | |
| 907 | /* |
no test coverage detected