mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
添加获取线程的方法
This commit is contained in:
parent
a4d7b3463e
commit
683c8eef15
@ -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);
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user