Delete 'src/kernel/CommRequest - 改.h'

yintianqi
p9prynkfo 2 months ago
parent 4b2fafbc15
commit b5a866474c

@ -1,87 +0,0 @@
// 版权声明表明该文件由Sogou, Inc.版权所有并且根据Apache License 2.0授权。
/*
Copyright (c) 2019 Sogou, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
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.
Author: Xie Han (xiehan@sogou-inc.com)
*/
#ifndef _COMMREQUEST_H_
#define _COMMREQUEST_H_
#include <errno.h>
#include <stddef.h>
#include "SubTask.h"
#include "Communicator.h"
#include "CommScheduler.h"
// 定义CommRequest类继承自SubTask和CommSession
class CommRequest : public SubTask, public CommSession
{
public:
// 构造函数初始化scheduler和object设置wait_timeout为0
CommRequest(CommSchedObject* object, CommScheduler* scheduler)
{
this->scheduler = scheduler;
this->object = object;
this->wait_timeout = 0;
}
// 获取请求对象的函数
CommSchedObject* get_request_object() const { return this->object; }
// 设置请求对象的函数
void set_request_object(CommSchedObject* object) { this->object = object; }
// 获取等待超时时间的函数
int get_wait_timeout() const { return this->wait_timeout; }
// 设置等待超时时间的函数
void set_wait_timeout(int timeout) { this->wait_timeout = timeout; }
public:
// 虚函数dispatch用于调度请求
virtual void dispatch()
{
if (this->scheduler->request(this, this->object, this->wait_timeout,
&this->target) < 0)
{
this->handle(CS_STATE_ERROR, errno);
}
}
protected:
// 状态和错误码成员变量
int state;
int error;
// 目标对象指针
CommTarget* target;
// 超时原因的定义
#define TOR_NOT_TIMEOUT 0
#define TOR_WAIT_TIMEOUT 1
#define TOR_CONNECT_TIMEOUT 2
#define TOR_TRANSMIT_TIMEOUT 3
// 超时原因变量
int timeout_reason;
// 成员变量,包括超时时间、请求对象指针和调度器指针
int wait_timeout;
CommSchedObject* object;
CommScheduler* scheduler;
// 虚函数handle用于处理请求状态和错误
virtual void handle(int state, int error);
};
#endif
Loading…
Cancel
Save