rakyll/coop hiện có 1.2k sao trên GitHub, viết chủ yếu bằng Go. Cheat sheet for some of the common concurrent flows in Go
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Note: This package became obsolete. I started it when I was learning Go a couple of years ago. I see so many better ways to implement them all now, so don't keep using this package as an ultimate reference.
coop contains some of the most common concurrent program flows I personally use in Go. I'm suggesting you to use this package as a snippets reference/cheat sheet instead of a library. The functionally provided in this package can be obtained in many different ways, and frankly with more performant implementations depending on the type of your problem.
coop contains implementations for the following flows:
coop.At(time, fn)
Runs fn at t, returns a boolean channel that will receive a message after fn returns. The following example, prints "Hello World" in a minute and blocks the goroutine its running in until fn is completed.
done := coop.At(time.Now().Add(time.Minute), func() {
fmt.Println("Hello world")
})
<-done // wait for fn to be done
coop.Until(time, duration, fn)
Runs fn once in every provided duration until t, returns a boolean channel that will receive a message after fn returns. The following example prints "Hello world" every minute until tomorrow, and blocks the goroutine its running in until the job is completed.
Runs fn after duration, returns a boolean channel that will receive a message after fn returns. The following example prints "Hello world" after a second and blocks until fn is completed.
Runs fn, and cancels the running job if timeout is exceeded. The following example will timeout and fn will return immediately ("Hello world will not printed"), the value read from the done channel will be false if timeout occurs, true if fn is completed.
done := coop.Timeout(time.Second, func() {
time.Sleep(time.Hour)
fmt.Println("Hello world")
})
<-done // will return false, because timeout occurred
coop.All(fns...)
Runs the list of fns concurrently, returns a boolean channel that will receive a message after all of the fns are completed. The following example will start 4 printing jobs concurrently and wait until all of them are completed.
Similar to coop.All, but with limiting. Runs the list of fns concurrently, but at most num fns at a time. Returns a boolean channel that will receive a message after all of the fns are completed. The following example will start 3 printing jobs immediately, and run the left out one once the first 3 is completed. It will block the goroutine until all 4 are finished.
Runs fn n time concurrently, returns a boolean channel that indicates all runs are completed. The following example prints "Hello world" 5 times, and waits for all printing jobs are finished.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/rakyll/coop là nguồn chính thức.
rakyll/coop có bao nhiêu sao?
rakyll/coop có 1.2k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/rakyll/coop. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
rakyll/coop có phải mã nguồn mở không?
TopGit chưa ghi nhận license cho rakyll/coop. Phần lớn repo public trên GitHub là mã nguồn mở, nhưng điều khoản khác nhau từng repo — mở file LICENSE để xác nhận.
rakyll/coop còn đang phát triển không?
Commit gần nhất trên rakyll/coop là 10.9 năm trước (theo timestamp GitHub). Repo có 44 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
rakyll/coop là gì?
rakyll/coop (rakyll/coop) là dự án Go trên GitHub. Theo mô tả gốc: Cheat sheet for some of the common concurrent flows in Go
rakyll/coop viết bằng ngôn ngữ gì?
rakyll/coop chủ yếu viết bằng Go. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về coop?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về coop.