Delete tc_epoller.h

This commit is contained in:
Douwanna 2020-06-02 18:57:44 +08:00 committed by GitHub
parent 30cabb8c4d
commit 58849eb417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,298 +0,0 @@
/**
* Tencent is pleased to support the open source community by making Tars available.
*
* Copyright (C) 2016THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
#ifndef __TC_EPOLLER_H_
#define __TC_EPOLLER_H_
#include "util/tc_platform.h"
#include "util/tc_socket.h"
#include <cassert>
#if TARGET_PLATFORM_IOS
#include "sys/event.h"
const int EPOLLIN = 0x0001;
const int EPOLLOUT = 0x0002;
const int EPOLLERR = 0x0004;
typedef kevent64_s epoll_event;
#else
#include "sys/epoll.h"
#endif
namespace tars
{
/////////////////////////////////////////////////
/**
* @file tc_epoller.h
* @brief epoll操作封装类
* @brief Epoll operation encapsulation class
*/
/////////////////////////////////////////////////
/**
* @brief epoll异常类
* @brief epoll exception class
*/
struct TC_Epoller_Exception : public TC_Exception
{
TC_Epoller_Exception(const string &buffer, int err) : TC_Exception(buffer, err) {};
~TC_Epoller_Exception() {};
};
/**
* @brief epoller操作类EPOLLET方式做触发
* @brief epoller operation class, EPOLLET has been used by default for triggering
*/
class TC_Epoller
{
public:
/**
* @brief epoll从wait中醒过来
* @brief Notice epoll to wake up from 'wait'
*/
class NotifyInfo
{
public:
NotifyInfo();
~NotifyInfo();
/**
*
* Initialization
*/
void init(TC_Epoller *ep);
/**
*
* Add corresponding data
*/
void add(uint64_t data);
/**
* notify醒过来
* Notice notify to wake up
*/
void notify();
/**
*
* Diposit
*/
void release();
/**
* fd
* Get notifyFd
*/
int notifyFd();
/**
* ,
* Clear up notice, otherwise, it will always respond
*/
// void clear();
protected:
//通知fd
TC_Socket _notify;
TC_Socket _notifyClient;
// bool _clear = true;
TC_Epoller *_ep;
/*Events associated with the notification handle*/
uint64_t _data; //关联到通知句柄的事件
};
/**
* @brief .
* @brief Constructor Function
*
* @param bEt ET模式
* @param bEt The default is et mode, which is notified when the status changes
*/
TC_Epoller();
/**
* @brief .
* @brief Destructor
*/
~TC_Epoller();
/**
* @brief epoll句柄.
* @brief Generate epoll handle.
*
* @param max_connections epoll服务需要支持的最大连接数
* @param max_connections Maximum number of connections the epoll service needs to support
*/
void create(int max_connections);
/**
* @brief
*
* @param
*/
void close();
/**
* @brief .
* @brief Add listening handle.
*
* @param fd
* @param fd handle
* @param data , epoll_event中获取到
* @param data auxiliary data that can be obtained in epoll_event subsequently
* @param event EPOLLIN|EPOLLOUT
* @param event Events to be listened on EPOLLIN|EPOLLOUT
*
*/
void add(SOCKET_TYPE fd, uint64_t data, int32_t event);
/**
* @brief .
* @brief Modify handle event
*
* @param fd
* @param fd handle
* @param data , epoll_event中获取到
* @param data auxiliary data that can be obtained in epoll_event subsequently
* @param event EPOLLIN|EPOLLOUT
* @param event Events to be listened on EPOLLIN|EPOLLOUT
*/
void mod(SOCKET_TYPE fd, uint64_t data, int32_t event);
/**
* @brief .
* @brief Delete handle event.
*
* @param fd
* @param fd handle
* @param data , epoll_event中获取到
* @param data auxiliary data that can be obtained in epoll_event subsequently
* @param event EPOLLIN|EPOLLOUT
* @param event Events to be listened on EPOLLIN|EPOLLOUT
*/
void del(SOCKET_TYPE fd, uint64_t data, int32_t event);
/**
* @brief .
* @brief wait time
*
* @param millsecond
* @return int
* @return int Number of handles triggered by events
*/
int wait(int millsecond);
/**
* @brief .
* @brief Get the triggered handle
*
* @return struct epoll_event&
* @return Struct epoll_event& triggered event
*/
epoll_event& get(int i);// { assert(_pevs != 0); return _pevs[i]; }
/**
* @brief
* @brief whether it have event to read
*
* @return
*/
static bool readEvent(const epoll_event &ev);
/**
* @brief
* @brief whether it have event to write
*
* @return
*/
static bool writeEvent(const epoll_event &ev);
/**
* @brief
* @brief whether it have eception event
*
* @return
*/
static bool errorEvent(const epoll_event &ev);
/**
* @brief /
* @brief Get low/high bit data
* @param high: true:, false:
* @param high: true:high level, false:low level
* @return
*/
static uint32_t getU32(const epoll_event &ev, bool high);
/**
* @brief 64bit数据
* @brief Get 64 bit data
* @return
*/
static uint64_t getU64(const epoll_event &ev);
protected:
/**
* @brief epollEPOLL设为边缘触发EPOLLET模式
* @brief Control epoll, set EPOLL to Edge Trigger EPOLLET mode
* @param fd create函数时被赋值
* @param fd Handle, assigned when creating function
* @param data , epoll_event中获取到
* @param data auxiliary data that can be obtained in epoll_event subsequently
* @param event
* @param event the event to be listened
* @param op EPOLL_CTL_ADD fd到epfd中
* EPOLL_CTL_MODfd的监听事件
* EPOLL_CTL_DELepfd中删除一个fd
* @param op EPOLL_CTL_ADDRegister new FD into EPFD
* EPOLL_CTL_MODModify the monitoring events for registered fd
* EPOLL_CTL_DELDelete an FD from epfd
*
*/
void ctrl(SOCKET_TYPE fd, uint64_t data, uint32_t events, int op);
protected:
/**
* epoll
*/
#if TARGET_PLATFORM_WINDOWS
void* _iEpollfd;
#else
int _iEpollfd;
#endif
/**
*
* The max amount of connections
*/
int _max_connections;
/**
*
* Event Set
*/
epoll_event *_pevs;
};
}
#endif