2013-06-30 10:46:29 +02:00
|
|
|
#pragma once
|
2014-11-10 01:21:50 +01:00
|
|
|
|
|
|
|
|
class CPUThread;
|
2015-01-17 17:14:58 +01:00
|
|
|
|
2014-09-11 21:18:19 +02:00
|
|
|
class CallbackManager
|
2013-06-30 10:46:29 +02:00
|
|
|
{
|
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-01-17 17:14:58 +01:00
|
|
|
|
2015-07-04 21:23:10 +02:00
|
|
|
std::shared_ptr<CPUThread> m_cb_thread;
|
2013-06-30 10:46:29 +02:00
|
|
|
|
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);
|
2013-06-30 10:46:29 +02:00
|
|
|
|
2015-07-04 21:23:10 +02:00
|
|
|
// register async callback, called in callback thread (accepts CPUThread&)
|
|
|
|
|
void Async(async_cb_t func);
|
2013-06-30 10:46:29 +02:00
|
|
|
|
2015-07-04 21:23:10 +02:00
|
|
|
// get one registered callback
|
|
|
|
|
check_cb_t Check();
|
2013-06-30 10:46:29 +02:00
|
|
|
|
2014-09-11 21:18:19 +02:00
|
|
|
void Init();
|
2013-06-30 10:46:29 +02:00
|
|
|
|
2014-09-11 21:18:19 +02:00
|
|
|
void Clear();
|
2014-04-10 00:54:32 +02:00
|
|
|
};
|