添加获取线程的方法

This commit is contained in:
xiongziliang 2020-05-08 09:52:05 +08:00
parent a4d7b3463e
commit 683c8eef15
2 changed files with 25 additions and 0 deletions

View File

@ -36,6 +36,22 @@ API_EXPORT mk_thread API_CALL mk_thread_from_tcp_session(mk_tcp_session ctx);
*/ */
API_EXPORT mk_thread API_CALL mk_thread_from_tcp_client(mk_tcp_client ctx); API_EXPORT mk_thread API_CALL mk_thread_from_tcp_client(mk_tcp_client ctx);
/**
* 线线
* 线线
* 线io事件线程
* @return 线
*/
API_EXPORT mk_thread API_CALL mk_thread_from_pool();
/**
* 线线
* 线线
* ZLMediaKit中后台线程用于dns解析mp4点播时的文件解复用
* @return 线
*/
API_EXPORT mk_thread API_CALL mk_thread_from_pool_work();
///////////////////////////////////////////线程切换///////////////////////////////////////////// ///////////////////////////////////////////线程切换/////////////////////////////////////////////
typedef void (API_CALL *on_mk_async)(void *user_data); typedef void (API_CALL *on_mk_async)(void *user_data);

View File

@ -12,6 +12,7 @@
#include "mk_tcp_private.h" #include "mk_tcp_private.h"
#include "Util/logger.h" #include "Util/logger.h"
#include "Poller/EventPoller.h" #include "Poller/EventPoller.h"
#include "Thread/WorkThreadPool.h"
using namespace std; using namespace std;
using namespace toolkit; using namespace toolkit;
@ -27,6 +28,14 @@ API_EXPORT mk_thread API_CALL mk_thread_from_tcp_client(mk_tcp_client ctx){
return (*client)->getPoller().get(); return (*client)->getPoller().get();
} }
API_EXPORT mk_thread API_CALL mk_thread_from_pool(){
return EventPollerPool::Instance().getPoller().get();
}
API_EXPORT mk_thread API_CALL mk_thread_from_pool_work(){
return WorkThreadPool::Instance().getPoller().get();
}
API_EXPORT void API_CALL mk_async_do(mk_thread ctx,on_mk_async cb, void *user_data){ API_EXPORT void API_CALL mk_async_do(mk_thread ctx,on_mk_async cb, void *user_data){
assert(ctx && cb); assert(ctx && cb);
EventPoller *poller = (EventPoller *)ctx; EventPoller *poller = (EventPoller *)ctx;