예제 #1
0
void
erts_exit_flush_async(void)
{
#ifdef USE_THREADS
    int i;
    ErtsAsync a;
    a.port = NIL;
    /*
     * Terminate threads in order to flush queues. We do not
     * bother to clean everything up since we are about to
     * terminate the runtime system and a cleanup would only
     * delay the termination.
     */
    for (i = 0; i < erts_async_max_threads; i++)
	async_add(&a, async_q(i));
    for (i = 0; i < erts_async_max_threads; i++)
	erts_thr_join(async->queue[i].aq.thr_id, NULL);
#endif
}
예제 #2
0
int exit_async()
{
    int i;

    /* terminate threads */
    for (i = 0; i < erts_async_max_threads; i++) {
        ErlAsync* a = (ErlAsync*) erts_alloc(ERTS_ALC_T_ASYNC,
                                             sizeof(ErlAsync));
        a->port = NIL;
        async_add(a, &async_q[i]);
    }

    for (i = 0; i < erts_async_max_threads; i++) {
        erts_thr_join(async_q[i].thr, NULL);
        erts_mtx_destroy(&async_q[i].mtx);
        erts_cnd_destroy(&async_q[i].cv);
    }
#ifndef ERTS_SMP
    erts_mtx_destroy(&async_ready_mtx);
#endif
    if (async_q)
        erts_free(ERTS_ALC_T_ASYNC_Q, (void *) async_q);
    return 0;
}