Lines Matching refs:threads

54 } *threads;
61 /* Disable all signals in the slave threads as X uses them for IO */
150 DBG(("%s: creating a thread pool of %d threads\n",
153 threads = malloc (sizeof(threads[0])*max_threads);
154 if (threads == NULL)
158 pthread_mutex_init(&threads[n].mutex, NULL);
159 pthread_cond_init(&threads[n].cond, NULL);
161 threads[n].func = NULL;
162 threads[n].arg = NULL;
163 if (pthread_create(&threads[n].thread, NULL,
164 __run__, &threads[n]))
168 threads[0].thread = pthread_self();
178 assert(pthread_self() == threads[0].thread);
181 assert(threads[id].func == NULL);
183 pthread_mutex_lock(&threads[id].mutex);
184 threads[id].func = func;
185 threads[id].arg = arg;
186 pthread_cond_signal(&threads[id].cond);
187 pthread_mutex_unlock(&threads[id].mutex);
198 if (t == threads[0].thread)
201 for (n = 1; threads[n].thread != t; n++)
206 pthread_mutex_lock(&threads[n].mutex);
207 threads[n].arg = (void *)(intptr_t)sig;
208 threads[n].func = NULL;
209 pthread_cond_signal(&threads[n].cond);
210 pthread_mutex_unlock(&threads[n].mutex);
220 assert(pthread_self() == threads[0].thread);
223 if (threads[n].func != NULL) {
224 pthread_mutex_lock(&threads[n].mutex);
225 while (threads[n].func)
226 pthread_cond_wait(&threads[n].cond, &threads[n].mutex);
227 pthread_mutex_unlock(&threads[n].mutex);
230 if (threads[n].arg != NULL) {
231 DBG(("%s: thread[%d] died from signal %d\n", __func__, n, (int)(intptr_t)threads[n].arg));
242 ERR(("%s: kill %d threads\n", __func__, max_threads));
244 assert(pthread_self() == threads[0].thread);
247 pthread_cancel(threads[n].thread);
250 pthread_join(threads[n].thread, NULL);
328 DBG(("%s: using %d threads for compositing %dx%d\n",