首页 > 编程语言 >go-epoll源码解析.md

go-epoll源码解析.md

时间:2023-11-10 12:23:21浏览次数:25  
标签:md epoll 源码 new go table events

golang-epoll模型源码解析

epoll

epoll is an io multipexing model in linux env.

img

epoll generate epoll table.

A new socket will be put into epoll table after bind and listen operation. Then we will get ready events with wait func

img

When epoll_wait() returns ready events,we need determine whether it's a new connection at first.

If new, fdDesc will be added to epoll table for listen events.

Else it means there have read or wirte events for established connection, we need call epollout or epollin

fdDesc

file Description

src/internal/poll/fd_uni.go

type FD struct{

    fdmu fdMutex // lock sysfd and serialize access to read and write methods

    sysfd int // system file name, immutable until close

    pd pollDesc // I/O poller

    ***


    isFile /// whether this is a file rather tan a network socket
}

now show struct pollDesc

待完善


标签:md,epoll,源码,new,go,table,events
From: https://www.cnblogs.com/erfeng/p/17730929.html

相关文章

  • go源码解析-map
    map简介golang的map主要是基于hash-bucket实现demoMap:=make(int,len)typehmapstruct{ //Note:theformatofthehmapisalsoencodedincmd/compile/internal/reflectdata/reflect.go. //Makesurethisstaysinsyncwiththecompiler'sdefinition. count......
  • 基于Hadoop的物品租赁系统的设计与实现-计算机毕业设计源码+LW文档
    开发语言:Java框架:springbootJDK版本:JDK1.8服务器:tomcat7数据库:mysql5.7(一定要5.7版本)数据库工具:Navicat11开发软件:eclipse/myeclipse/ideaMaven包:Maven3.3.9浏览器:谷歌浏览器数据库:DROPTABLEIFEXISTSaboutus;/*!40101SET@saved_cs_client=@@character_set_cl......
  • 2023-08-24:请用go语言编写。给定一个长度为n的数组arr, 现在你有一次机会, 将其中连续
    2023-08-24:请用go语言编写。给定一个长度为n的数组arr,现在你有一次机会,将其中连续的K个数全修改成任意一个值,请你计算如何修改可以使修改后的数列的最长不下降子序列最长。请输出这个最长的长度。最长不下降子序列:子序列中的每个数不小于在它之前的数。1<=k,n<=10^5,1<=a......
  • Go 设计模式中中介者模式
    鱼弦:内容合伙人、新星导师、全栈领域创作新星创作者、51CTO(Top红人+专家博主)、github开源爱好者(go-zero源码二次开发、游戏后端架构https://github.com/Peakchen) 中介者模式原理详细解释:中介者模式(MediatorPattern)是一种行为型设计模式,用于降低多个对象之间的直接通信,并使......
  • Go 设计模式中观察者模式
    鱼弦:内容合伙人、新星导师、全栈领域创作新星创作者、51CTO(Top红人+专家博主)、github开源爱好者(go-zero源码二次开发、游戏后端架构https://github.com/Peakchen)          观察者模式原理详细解释:观察者模式(ObserverPattern)是一种行为型设计模式,它定义了......
  • Golang锁简单使用
    golang主要有两种锁:互斥锁和读写锁互斥锁Mutex用于提供一种加锁机制(LockingMechanism),保证同一时刻只有一个goroutine在临界区运行packagemainimport( "fmt" "sync" "time")funcmain(){ varmutexsync.Mutex x:=0 gofunc(){ mutex.Lock() x=x+1......
  • Golang服务端断线重连
    断线重连的逻辑很简单,就是把用户存到服务器内存中,当客户端再次登录的时候,判断内存中是否有用户的值,有的话替换packagemainimport( "fmt" "github.com/gorilla/websocket" "log" "net/http" "sync" "time")typeClientstruct{ conn*we......
  • 记录使用mongotemplete关于时间查询时的大坑
    1、问题:在使用条件查询mongdb数据库的时候,涉及到使用时间范围来查询数据,比如当时使用的是:1990-01-01T00:00:00到1900-02-02T00:00:00查询的是1月1号到1月2号两天的数据,但是在使用Query.query(criteria);进行查询的时候,和使用Aggregation.match(criteria);进行查询得出的结果不......
  • Go 面向接口编程
    接口有什么用?就是存储未实现的方法,作为实现的此方法的结构体的实例的句柄。typeSayerinterface{ say()}typeDogstruct{}typeCatstruct{}func(*Dog)say(){ fmt.Println("Woewwoew")}func(*Cat)say(){ fmt.Println("Meowmeow")}funcmain(){ va......
  • Cmder - 想让你的windows下 cmd 和 SecureCRT 操作 Linux 一样帅吗
    想让你的windows下cmd和SecureCRT操作Linux一样帅的命令行显示吗。下载cmder绿色版,然后用我的配置文件,替换原来的文件启动就可以了配置文件下载:cmder配置下载另外加cmder添加到右击菜单中,到安装目录中,执行下面命令Cmder.exe/REGISTERALL将tail.exe复制到C:......