java怎么拦截某个对象
249
2022-10-06
Simple实现之Pipe代码
类Pipe实现了PipeConnection的接口,它实现了两个端口之间的类似管道的功能。
对于每一个pipe,内部都有一个Reader和一个Writer线程,分别用来处理这个Pipe有关的消息接收和请求的发送。线程DelayedDelivery用于故障注入测试:
class Pipe : public RefCountedObject {
class Reader : public Thread {
……
} reader_thread;
//接收线程,用于接收数据
class Writer : public Thread {
……
} writer_thread;
//发送线程,用于发送数据
SimpleMessenger *msgr; // msgr的指针
uint64_t conn_id; //分配给Pipe自己唯一的id
char *recv_buf; //接收缓存区
int recv_max_prefetch; //接收缓冲区一次预取的最大值
int recv_ofs; //接收的偏移量
int recv_len; //接收的长度
int sd; // pipe对应的socked fd
struct iovec msgvec[IOV_MAX]; //发送消息的iovec结构
int port; //链接端口
int peer_type; //链接对方的类型
entity_addr_t peer_addr; //对方地址
Messenger::Policy policy; //策略
Mutex pipe_lock;
int state; //当前链接的状态
atomic_t state_closed; //如果非0,那么状态为STATE_CLOSED
PipeConnectionRef connection_state; //PipeConnection的引用
utime_t backoff; // backoff的时间
map
DispatchQueue *in_q; //接收消息的DispatchQueue
list
Cond cond;
bool send_keepalive;
bool send_keepalive_ack;
utime_t keepalive_ack_stamp;
bool halt_delivery; //如果Pipe队列消毁,停止增加
__u32 connect_seq, peer_global_seq;
uint64_t out_seq; //发送消息的序列号
uint64_t in_seq, in_seq_acked; //接收到消息序号和ACK的序号
}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~