/* @wait Whether to wait for writeout thread to complete  */
static void flush_trace_file(bool wait)
/* @wait Whether to wait for writeout thread to complete  */
static void flush_trace_file(bool wait)
{
    lock_trace_lock();
    trace_available = true;
    g_cond_signal(trace_available_cond);
    if (wait) {
        g_cond_wait(trace_empty_cond, get_trace_lock_mutex());
    }
    unlock_trace_lock();
}