![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
golang
tydhot
gogogo
展开
-
golang自带的rpc 服务端
服务端通过register()方法将需要被远程调用的方法注册到map中。 func (server *Server) register(rcvr interface{}, name string, useName bool) error { s := new(service) s.typ = reflect.TypeOf(rcvr) s.rcvr = reflect.Valu...原创 2018-06-22 11:37:33 · 5719 阅读 · 0 评论 -
golang 1.10 mutex互斥锁源码
Mutex锁分为normal模式和starvation模式。一开始默认处于normal模式。在normal模式中,每个新加入竞争锁行列的协程都会直接参与到锁的竞争当中来,而处于starvation模式时,所有所有新进入的协程都会直接被放入等待队列中挂起,直到其所在队列之前的协程全部执行完毕。 在normal模式中协程的挂起等待时间如果大于某个值,就会进入starvation模式。 type ...原创 2018-05-13 18:10:54 · 1344 阅读 · 2 评论 -
go语言sync包的Map源码
Go语言在sync包中给出了线程安全的map。 Map的结构体比较简单。 type Map struct { mu Mutex // read contains the portion of the map's contents that are safe for // concurrent access (with or without mu held). // ...原创 2018-04-29 15:55:04 · 392 阅读 · 0 评论