Ejemplo n.º 1
0
// This is to be called when outside threads, such as the graphics thread, wants to
// schedule things to be executed on the main thread.
void ScheduleEvent_Threadsafe(int cyclesIntoFuture, int event_type, u64 userdata)
{
	std::lock_guard<std::mutex> lk(tsWriteLock);
	Event ne;
	ne.time = globalTimer + cyclesIntoFuture;
	ne.type = event_type;
	ne.userdata = userdata;
	tsQueue.Push(ne);
}
Ejemplo n.º 2
0
// This is to be called when outside threads, such as the graphics thread, wants to
// schedule things to be executed on the main thread.
void ScheduleEvent_Threadsafe(int cyclesIntoFuture, int event_type, u64 userdata)
{
	// TODO: Fix UI thread safety problems, and enable this assertion
	// _assert_msg_(POWERPC, !Core::IsCPUThread(), "ScheduleEvent_Threadsafe from wrong thread");
	std::lock_guard<std::mutex> lk(tsWriteLock);
	Event ne;
	ne.time = globalTimer + cyclesIntoFuture;
	ne.type = event_type;
	ne.userdata = userdata;
	tsQueue.Push(ne);
}
Ejemplo n.º 3
0
// This is to be called when outside threads, such as the graphics thread, wants to
// schedule things to be executed on the main thread.
void ScheduleEvent_Threadsafe(s64 cyclesIntoFuture, int event_type, u64 userdata)
{
	_assert_msg_(POWERPC, !Core::IsCPUThread(), "ScheduleEvent_Threadsafe from wrong thread");
	if (Core::g_want_determinism)
	{
		ERROR_LOG(POWERPC, "Someone scheduled an off-thread \"%s\" event while netplay or movie play/record "
		                   "was active.  This is likely to cause a desync.",
		                   event_types[event_type].name.c_str());
	}
	std::lock_guard<std::mutex> lk(tsWriteLock);
	Event ne;
	ne.time = g_globalTimer + cyclesIntoFuture;
	ne.type = event_type;
	ne.userdata = userdata;
	tsQueue.Push(ne);
}
Ejemplo n.º 4
0
void ScheduleEvent(s64 cycles_into_future, EventType* event_type, u64 userdata, FromThread from)
{
    _assert_msg_(POWERPC, event_type, "Event type is nullptr, will crash now.");

    bool from_cpu_thread;
    if (from == FromThread::ANY)
    {
        from_cpu_thread = Core::IsCPUThread();
    }
    else
    {
        from_cpu_thread = from == FromThread::CPU;
        _assert_msg_(POWERPC, from_cpu_thread == Core::IsCPUThread(),
                     "ScheduleEvent from wrong thread (%s)", from_cpu_thread ? "CPU" : "non-CPU");
    }

    if (from_cpu_thread)
    {
        s64 timeout = GetTicks() + cycles_into_future;

        // If this event needs to be scheduled before the next advance(), force one early
        if (!s_is_global_timer_sane)
            ForceExceptionCheck(cycles_into_future);

        s_event_queue.emplace_back(Event{timeout, s_event_fifo_id++, userdata, event_type});
        std::push_heap(s_event_queue.begin(), s_event_queue.end(), std::greater<Event>());
    }
    else
    {
        if (Core::g_want_determinism)
        {
            ERROR_LOG(POWERPC, "Someone scheduled an off-thread \"%s\" event while netplay or "
                      "movie play/record was active.  This is likely to cause a desync.",
                      event_type->name->c_str());
        }

        std::lock_guard<std::mutex> lk(s_ts_write_lock);
        s_ts_queue.Push(Event{g_global_timer + cycles_into_future, 0, userdata, event_type});
    }
}