rpcsx/rpcs3/Emu/SysCalls/Callback.h

31 lines
599 B
C
Raw Normal View History

#pragma once
class CPUThread;
2014-09-11 21:18:19 +02:00
class CallbackManager
{
2015-07-04 21:23:10 +02:00
using check_cb_t = std::function<s32(CPUThread&)>;
using async_cb_t = std::function<void(CPUThread&)>;
2014-09-11 21:18:19 +02:00
std::mutex m_mutex;
2015-03-16 01:21:40 +01:00
2015-07-04 21:23:10 +02:00
std::queue<check_cb_t> m_check_cb;
std::queue<async_cb_t> m_async_cb;
2015-07-04 21:23:10 +02:00
std::shared_ptr<CPUThread> m_cb_thread;
2014-09-11 21:18:19 +02:00
public:
2015-07-04 21:23:10 +02:00
// register checked callback (accepts CPUThread&, returns s32)
void Register(check_cb_t func);
2015-07-04 21:23:10 +02:00
// register async callback, called in callback thread (accepts CPUThread&)
void Async(async_cb_t func);
2015-07-04 21:23:10 +02:00
// get one registered callback
check_cb_t Check();
2014-09-11 21:18:19 +02:00
void Init();
2014-09-11 21:18:19 +02:00
void Clear();
};