Exemplo n.º 1
0
static DWORD WINAPI internal_thread_func(LPVOID param) {
    pa_thread *t = param;
    assert(t);

    pa_run_once(&thread_tls_once, thread_tls_once_func);
    pa_tls_set(thread_tls, t);

    t->thread_func(t->userdata);

    return 0;
}
Exemplo n.º 2
0
static void thread_func(void *data) {
    pa_tls_set(tls, data);

    pa_log_info("thread_func() for %s starting...", (char*) pa_tls_get(tls));

    pa_mutex_lock(mutex);

    for (;;) {
        int k, n;

        pa_log_info("%s waiting ...", (char*) pa_tls_get(tls));

        for (;;) {

            if (magic_number < 0)
                goto quit;

            if (magic_number != 0)
                break;

            pa_cond_wait(cond1, mutex);
        }

        k = magic_number;
        magic_number = 0;

        pa_mutex_unlock(mutex);

        pa_run_once(&once, once_func);

        pa_cond_signal(cond2, 0);

        pa_log_info("%s got number %i", (char*) pa_tls_get(tls), k);

        /* Spin! */
        for (n = 0; n < k; n++)
            pa_thread_yield();

        pa_mutex_lock(mutex);
    }

quit:

    pa_mutex_unlock(mutex);

    pa_log_info("thread_func() for %s done...", (char*) pa_tls_get(tls));
}
Exemplo n.º 3
0
pa_thread* pa_thread_self(void) {
    pa_run_once(&thread_tls_once, thread_tls_once_func);
    return pa_tls_get(thread_tls);
}