spiochannel.hpp
来自「spserver 是一个实现了半同步/半异步(Half-Sync/Half-As」· HPP 代码 · 共 69 行
HPP
69 行
/* * Copyright 2007 Stephen Liu * For license terms, see the file COPYING along with this library. */#ifndef __spiochannel_hpp__#define __spiochannel_hpp__class SP_Session;class SP_Buffer;struct evbuffer;struct iovec;class SP_IOChannel {public: virtual ~SP_IOChannel(); // call by an independence thread, can block // return -1 : terminate session, 0 : continue virtual int init( int fd ) = 0; // run in event-loop thread, cannot block // return the number of bytes received, or -1 if an error occurred. virtual int receive( SP_Session * session ) = 0; // run in event-loop thread, cannot block // return the number of bytes sent, or -1 if an error occurred. virtual int transmit( SP_Session * session );protected: static struct evbuffer * getEvBuffer( SP_Buffer * buffer ); // returns the number of bytes written, or -1 if an error occurred. virtual int write_vec( struct iovec * iovArray, int iovSize ) = 0;};class SP_IOChannelFactory {public: virtual ~SP_IOChannelFactory(); virtual SP_IOChannel * create() const = 0;};class SP_DefaultIOChannelFactory : public SP_IOChannelFactory {public: SP_DefaultIOChannelFactory(); virtual ~SP_DefaultIOChannelFactory(); virtual SP_IOChannel * create() const;};class SP_DefaultIOChannel : public SP_IOChannel {public: SP_DefaultIOChannel(); ~SP_DefaultIOChannel(); virtual int init( int fd ); virtual int receive( SP_Session * session );protected: virtual int write_vec( struct iovec * iovArray, int iovSize ); int mFd;};#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?