Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/daheige/concurrency-in-go
/ functions
Functions
155 in github.com/daheige/concurrency-in-go
⨍
Functions
155
◇
Types & classes
10
↓ 248 callers
Method
Println
(args ...interface{})
part20/safe_go.go:29
↓ 4 callers
Function
consumer
(ch <-chan int)
part10/pro_cust_async.go:93
↓ 3 callers
Function
product
(ch chan<- int)
part10/pro_cust_async.go:83
↓ 3 callers
Function
worker
(wg *sync.WaitGroup, n int)
part19/t.go:25
↓ 2 callers
Function
catchRecover
()
part22/panic_catch/panic_catch.go:46
↓ 2 callers
Function
consumer
(c <-chan int, done chan struct{})
part5/pro_cust.go:16
↓ 2 callers
Function
doWork
()
part22/panic_catch/panic_catch.go:52
↓ 2 callers
Function
generator
不停地产生int
part12/select.go:32
↓ 2 callers
Function
printNum
多任务资源竞争
part6/runtime_task.go:10
↓ 2 callers
Function
produce
(p chan<- int)
part5/pro_cust.go:9
↓ 1 callers
Function
AsyncCallByCtx
AsyncCallByCtx 通过ctx timeout方式实现fn调度,超时就取消fn执行
part22/time_demo/main.go:55
↓ 1 callers
Function
AsyncCallWithCtx
AsyncCallWithCtx do task with ctx
part22/timeout/timeout.go:38
↓ 1 callers
Function
CatchStack
捕获指定stack信息,一般在处理panic/recover中处理 返回完整的堆栈信息和函数调用信息
part9/stack.go:56
↓ 1 callers
Function
Consumer
消费者
part11/chan_demo.go:22
↓ 1 callers
Method
Count
()
part14/cache.go:17
↓ 1 callers
Method
Do
Do 安全的执行fn
part20/safe_go.go:54
↓ 1 callers
Method
DoQuery
DoQuery 模拟查询
part8/select_one.go:27
↓ 1 callers
Method
Get
(string)
part14/cache.go:14
↓ 1 callers
Method
Increment
Increment 利用mutex枷锁和解锁机制 通过使用内存访问同步原语,你可以隐藏从呼叫者锁定关键部分的实现细节,但不会给调用者带来复杂性。 这是一个线程安全类型的小例子:
part2/demo.go:17
↓ 1 callers
Function
New
New returns 创建一个safeGo实例
part20/safe_go.go:33
↓ 1 callers
Function
NewCache
(cacheType string)
part14/cache.go:109
↓ 1 callers
Function
Productor
生产者
part11/chan_demo.go:15
↓ 1 callers
Method
Set
(string, interface{}, time.Duration)
part14/cache.go:15
↓ 1 callers
Function
Stack
获取完整的堆栈信息 Stack returns a formatted stack trace of the goroutine that calls it. It calls runtime.Stack with a large enough buffer to capture the entir
part9/stack.go:42
↓ 1 callers
Function
Task
(taskch, resch chan int, exitch chan bool)
part11/chan_work.go:5
↓ 1 callers
Function
addele
当启动多个goroutine时,如果其中一个goroutine异常了,并且我们并没有对进行异常处理,那么整个程序都会终止 所以我们在编写程序时候最好每个goroutine所运行的函数都做异常处理,异常处理采用recover
part11/cal.go:28
↓ 1 callers
Function
cal
(a int , b int )
part11/cal.go:8
↓ 1 callers
Function
cal2
(a int , b int ,wg *sync.WaitGroup)
part11/sync_demo.go:50
↓ 1 callers
Function
cal3
(a int , b int ,done chan bool)
part11/sync_demo.go:57
↓ 1 callers
Function
consume
(data chan string)
part17/app_graceful.go:63
↓ 1 callers
Function
consumer
(msgCh <-chan string)
part10/prodemo/app.go:70
↓ 1 callers
Function
consumer1
(ch <-chan int)
part10/demo.go:28
↓ 1 callers
Function
cust
只能读取
part6/chan_3.go:22
↓ 1 callers
Function
doStuff
(done chan struct{})
part12/ctx.go:31
↓ 1 callers
Function
getUser
getUser 返回一个指针类型
part18/app.go:13
↓ 1 callers
Function
getUser2
getUser2 模拟参数泄露
part18/app.go:19
↓ 1 callers
Function
getUser3
getUser3 避免参数泄露,让返回值分配在堆上 .\app.go:25:15: moved to heap: u
part18/app.go:26
↓ 1 callers
Function
handler
** 把上面的for{}打开 % go run ctx.go 2020/06/21 17:31:11 task exec begin 2020/06/21 17:31:16 timeout 2020/06/21 17:31:16 task exec end 2020/06/21 17:31:21 1
part12/ctx.go:71
↓ 1 callers
Function
limit
(next http.Handler)
part16/http_rate.go:18
↓ 1 callers
Function
makeRndNum
()
part8/select.go:10
↓ 1 callers
Function
printNum1
多任务资源竞争
part6/chan.go:12
↓ 1 callers
Function
printNum2
(n int)
part6/chan.go:21
↓ 1 callers
Function
proAndConsume
(exit chan struct{})
part17/app_graceful2.go:51
↓ 1 callers
Function
product1
(ch chan<- int)
part10/demo.go:18
↓ 1 callers
Function
productDone
(ch chan<- int, done chan<- struct{})
part10/pro_cust_async.go:101
↓ 1 callers
Function
production
单方向的通道,写入
part6/chan_3.go:12
↓ 1 callers
Function
production
(data chan string, exit chan struct{})
part17/app_graceful.go:49
↓ 1 callers
Function
production
(msgCh chan<- string, done <-chan struct{})
part10/prodemo/app.go:46
↓ 1 callers
Function
pump1
(ch chan int)
part8/select_pump.go:19
↓ 1 callers
Function
pump2
(ch chan int)
part8/select_pump.go:25
↓ 1 callers
Function
query
(conns []Conn)
part8/select_one.go:37
↓ 1 callers
Function
rpc
模拟rpc调用
part12/ctx.go:96
↓ 1 callers
Function
send
(c chan int)
part11/select_case.go:12
↓ 1 callers
Function
shuffle
产生[0-n]之间的[]int
part12/dotask.go:15
↓ 1 callers
Function
suck
(ch1, ch2 chan int)
part8/select_pump.go:31
↓ 1 callers
Function
test
(ch chan int)
part5/gofunc.go:18
↓ 1 callers
Function
test
()
part9/stack.go:16
↓ 1 callers
Function
test
()
part6/runtime_2.go:8
↓ 1 callers
Function
test
(c chan bool, n int)
part13/more_cpu.go:15
↓ 1 callers
Function
w
()
part15/chan_demo.go:70
↓ 1 callers
Function
worker
(id int, jobs <-chan int, results chan<- int)
part21/work_pool.go:34
Function
AsyncCall
AsyncCall fn func() 通过timer模式进行超时控制
part22/time_demo/main.go:34
Function
AsyncCall
AsyncCall 第一种:使用time.NewTimer
part22/timeout/timeout.go:14
Method
Count
()
part14/cache.go:78
Method
Del
(string)
part14/cache.go:16
Method
Del
(key string)
part14/cache.go:67
Method
Expire
(key string, duration time.Duration)
part14/cache.go:19
Method
Expire
(key string, d time.Duration)
part14/cache.go:125
Method
Get
(key string)
part14/cache.go:32
Function
HelloHandler
(w http.ResponseWriter, req *http.Request)
part16/ratelimit/app.go:10
Method
Incr
(key string, step int64)
part14/cache.go:18
Method
Incr
(key string, step int64)
part14/cache.go:84
Function
Index
Index index.
part23/http_server_panic.go:43
Function
MockPanic
MockPanic test panic.
part23/http_server_panic.go:48
Method
Set
(key string, val interface{}, d time.Duration)
part14/cache.go:50
Function
hello
()
part3/chan_sem.go:30
Function
hello2
()
part3/chan_sem.go:49
Function
hello3
fatal error: all goroutines are asleep - deadlock,产生死锁
part3/chan_sem.go:65
Function
main
()
part2/demo.go:23
Function
main
()
part12/dotask.go:21
Function
main
()
part12/ctx.go:46
Function
main
()
part12/select.go:9
Function
main
()
part14/cache.go:145
Function
main
()
part3/select_case.go:5
Function
main
()
part3/select_break.go:9
Function
main
()
part3/chan_2.go:5
Function
main
()
part3/chan.go:9
Function
main
()
part3/chan_sem.go:5
Function
main
常见的超时处理
part3/select_after.go:9
Function
main
()
part3/select.go:8
Function
main
非安全性并发操作 在这个例子中,你可以看到,我们不需要通过通信同步内存访问或共享数据。
part4/production_2.go:11
Function
main
()
part4/rnd.go:10
Function
main
并发安全:将通道的读写约束在指定范围内
part4/production.go:6
Function
main
()
part20/safe_go.go:9
Function
main
构建一个缓冲型的 channel,容量为 4。接着遍历任务列表,每个任务启动一个 goroutine 去完成。 真正执行任务,访问第三方的动作在 w() 中完成,在执行 w() 之前,先要从 limit 中拿“许可证”, 拿到许可证之后,才能执行 w(),并且在执行完任务,要将“许可证”归还。 这样
part15/chan_demo.go:23
Function
main
()
part15/server_http.go:13
Function
main
()
part5/done_struct.go:8
Function
main
()
part5/gofunc.go:5
Function
main
()
part5/pro_cust.go:25
Function
main
()
part9/app_2.go:10
next →
1–100 of 155, ranked by callers