ZLMediaKit/api/include/mk_thread.h

87 lines
2.4 KiB
C++
Raw Normal View History

2019-12-27 10:46:40 +08:00
/*
2020-04-04 20:30:09 +08:00
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
2019-12-27 10:46:40 +08:00
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
2020-04-04 20:30:09 +08:00
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
* may be found in the AUTHORS file in the root of the source tree.
2019-12-27 10:46:40 +08:00
*/
#ifndef MK_THREAD_H
#define MK_THREAD_H
#include <assert.h>
#include "mk_common.h"
#include "mk_tcp.h"
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////事件线程/////////////////////////////////////////////
typedef void* mk_thread;
/**
* tcp会话对象所在事件线程
* @param ctx tcp会话对象
* @return 线
*/
API_EXPORT mk_thread API_CALL mk_thread_from_tcp_session(mk_tcp_session ctx);
/**
* tcp客户端对象所在事件线程
* @param ctx tcp客户端
* @return 线
*/
API_EXPORT mk_thread API_CALL mk_thread_from_tcp_client(mk_tcp_client ctx);
///////////////////////////////////////////线程切换/////////////////////////////////////////////
typedef void (API_CALL *on_mk_async)(void *user_data);
/**
* 线
* @param ctx 线
* @param cb
* @param user_data
*/
API_EXPORT void API_CALL mk_async_do(mk_thread ctx,on_mk_async cb, void *user_data);
/**
* 线
* @param ctx 线
* @param cb
* @param user_data
*/
API_EXPORT void API_CALL mk_sync_do(mk_thread ctx,on_mk_async cb, void *user_data);
///////////////////////////////////////////定时器/////////////////////////////////////////////
typedef void* mk_timer;
/**
*
* @return ()0
*/
typedef uint64_t (API_CALL *on_mk_timer)(void *user_data);
/**
*
* @param ctx 线
* @param delay_ms
* @param cb
* @param user_data
* @return
*/
API_EXPORT mk_timer API_CALL mk_timer_create(mk_thread ctx,uint64_t delay_ms, on_mk_timer cb, void *user_data);
/**
*
* @param ctx
*/
API_EXPORT void API_CALL mk_timer_release(mk_timer ctx);
#ifdef __cplusplus
}
#endif
#endif //MK_THREAD_H