From 4f2f812bd86b6a9b48509fed0701b1c0f978fb0b Mon Sep 17 00:00:00 2001 From: pwsqyok56 <18570688110@163.com> Date: Mon, 16 Dec 2024 22:20:34 +0800 Subject: [PATCH 1/3] Delete 'src/kernel/CMakeLists.txt' --- src/kernel/CMakeLists.txt | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 src/kernel/CMakeLists.txt diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt deleted file mode 100644 index 209f0ec..0000000 --- a/src/kernel/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -cmake_minimum_required(VERSION 3.6) -project(kernel) - -if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") - set(IOSERVICE_FILE IOService_linux.cc) -elseif (UNIX) - set(IOSERVICE_FILE IOService_thread.cc) -else () - message(FATAL_ERROR "IOService unsupported.") -endif () - -set(SRC - ${IOSERVICE_FILE} - mpoller.c - poller.c - rbtree.c - msgqueue.c - thrdpool.c - CommRequest.cc - CommScheduler.cc - Communicator.cc - Executor.cc - SubTask.cc -) - -add_library(${PROJECT_NAME} OBJECT ${SRC}) - From 4b2fafbc156d5b9fe06c15d8524c498ae791d0b0 Mon Sep 17 00:00:00 2001 From: cmz <3256005191@qq.com> Date: Mon, 16 Dec 2024 22:28:49 +0800 Subject: [PATCH 2/3] cmz --- src/kernel/CommRequest - 改.h | 87 ++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/kernel/CommRequest - 改.h diff --git a/src/kernel/CommRequest - 改.h b/src/kernel/CommRequest - 改.h new file mode 100644 index 0000000..e99115a --- /dev/null +++ b/src/kernel/CommRequest - 改.h @@ -0,0 +1,87 @@ +// °æȨÉùÃ÷£¬±íÃ÷¸ÃÎļþÓÉ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 +#include +#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 \ No newline at end of file From b5a866474c5ee94e68754224c9daf23121f25b62 Mon Sep 17 00:00:00 2001 From: p9prynkfo <1910500091@qq.com> Date: Mon, 16 Dec 2024 22:46:27 +0800 Subject: [PATCH 3/3] =?UTF-8?q?Delete=20'src/kernel/CommRequest=20-=20?= =?UTF-8?q?=E6=94=B9.h'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/kernel/CommRequest - 改.h | 87 ---------------------------------- 1 file changed, 87 deletions(-) delete mode 100644 src/kernel/CommRequest - 改.h diff --git a/src/kernel/CommRequest - 改.h b/src/kernel/CommRequest - 改.h deleted file mode 100644 index e99115a..0000000 --- a/src/kernel/CommRequest - 改.h +++ /dev/null @@ -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 -#include -#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 \ No newline at end of file