mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-15 17:30:53 +08:00
122 lines
2.2 KiB
C++
122 lines
2.2 KiB
C++
|
#pragma once
|
|||
|
#include "acl_cpp/acl_cpp_define.hpp"
|
|||
|
#include "acl_cpp/stdlib/locker.hpp"
|
|||
|
#include "acl_cpp/ipc/ipc_server.hpp"
|
|||
|
|
|||
|
struct acl_pthread_pool_t;
|
|||
|
|
|||
|
namespace acl {
|
|||
|
|
|||
|
class ipc_client;
|
|||
|
|
|||
|
class ACL_CPP_API ipc_request
|
|||
|
{
|
|||
|
public:
|
|||
|
ipc_request();
|
|||
|
virtual ~ipc_request();
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ýӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD> IO <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>ģʽ
|
|||
|
*/
|
|||
|
virtual void run(ipc_client* ipc);
|
|||
|
|
|||
|
#ifdef WIN32
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ýӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD> WIN32 <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>ģʽ
|
|||
|
*/
|
|||
|
virtual void run(HWND hWnd);
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> WIN32 <EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param hWnd {HWND} <EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void set_hwnd(HWND hWnd)
|
|||
|
{
|
|||
|
hWnd_ = hWnd;
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> WIN32 <EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @return {HWND} <EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
HWND get_hwnd(void) const
|
|||
|
{
|
|||
|
return (hWnd_);
|
|||
|
}
|
|||
|
#endif
|
|||
|
private:
|
|||
|
#ifdef WIN32
|
|||
|
HWND hWnd_;
|
|||
|
#endif
|
|||
|
};
|
|||
|
|
|||
|
class ACL_CPP_API ipc_service : public ipc_server
|
|||
|
{
|
|||
|
public:
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><EFBFBD>
|
|||
|
* @param nthread {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ > 1 <EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳߳أ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
|||
|
* @param ipc_keep {bool} <EFBFBD>ڲ<EFBFBD> IPC <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>Ƿֳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֳ<EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>Ч<EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
ipc_service(int nthread, bool ipc_keep = true);
|
|||
|
|
|||
|
virtual ~ipc_service();
|
|||
|
|
|||
|
#ifdef WIN32
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> WIN32 <EFBFBD><EFBFBD>Ϣģʽʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫʵ<EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ָýӿ<EFBFBD>
|
|||
|
* @param hWnd {HWND} <EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param msg {UINT} <EFBFBD>û<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>
|
|||
|
* @param wParam {WPARAM} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param lParam {LPARAM} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
virtual void win32_proc(HWND hWnd, UINT msg,
|
|||
|
WPARAM wParam, LPARAM lParam);
|
|||
|
#endif
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD> ipc <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @return {ipc_client*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> NULL <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
ipc_client* peek_conn();
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ipc <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ӷŻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param conn {ipc_client*} ipc <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void push_conn(ipc_client* conn);
|
|||
|
protected:
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param req {ipc_request*}
|
|||
|
*/
|
|||
|
void request(ipc_request* req);
|
|||
|
private:
|
|||
|
bool ipc_keep_;
|
|||
|
acl_pthread_pool_t* thread_pool_;
|
|||
|
#ifdef WIN32
|
|||
|
HWND hWnd_;
|
|||
|
HINSTANCE hInstance_;
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Windows <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>ʽ<EFBFBD>£<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><EFBFBD>ھ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
virtual bool create_window(void);
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Windows <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>ʽ<EFBFBD>£<EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><EFBFBD>ھ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
virtual void close_window(void);
|
|||
|
#endif
|
|||
|
|
|||
|
locker lock_;
|
|||
|
std::list<ipc_client*> conn_pool_;
|
|||
|
};
|
|||
|
|
|||
|
} // namespace acl
|