⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 netkicker.h

📁 nandflash文件系统源代码
💻 H
字号:
//---------------------------------------------------------- -*- Mode: C++ -*-// $Id:$//// Created 2008/05/04// Author: Sriram Rao//// Copyright 2008 Quantcast Corp.//// This file is part of Kosmos File System (KFS).//// 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.//// \brief In a multi-threaded setup, the net-manager runs on a// separate thread.  It has a poll loop with a delay of N secs; during// this time, any messages generated interally maybe held waiting for// the net-manager thread to wake up.  This has the effect of// introducing N sec delay for sending outbound messages.  To force// the net-manager to wake up, create a "net kicker" object and write// some data to it.  That is, create a pipe and make the pipe fd part// of the net-manager's poll loop; whenever we write data to the pipe,// the net-manager will wake up and service out-bound messages.//// ----------------------------------------------------------------------------#ifndef LIBKFSIO_NETKICKER_H#define LIBKFSIO_NETKICKER_H#include <unistd.h>#include "KfsCallbackObj.h"#include "NetManager.h"namespace KFS{    class NetKicker : public KfsCallbackObj {    public:        NetKicker();        /// Register the "read" part of the pipe with the net manager.        void Init(NetManager &netManager);        /// The "write" portion of the pipe writes one byte on the fd.        void Kick();        /// This is the callback from the net-manager to drain out the        /// bytes written on the pipe        int Drain();        int GetFd() const {            return mNetConnection->GetFd();        }    private:        int mPipeFds[2];        // the "read" part of the pipe needs to be made part of the        // poll loop.  the net-manager understands net connection        // objects; so, wrap the fd into a connection and hand that        // off to the net manager.        NetConnectionPtr mNetConnection;    };}#endif // LIBKFSIO_NETKICKER_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -