Code Monkey home page Code Monkey logo

co's Introduction

Co

A concurrency lib project with GENERIC SUPPORTED dedicate to help developer ease the pain of dealing goroutine and channel when coding 2 more lines of channel code become annoying.

Co provides a lot of (at least in planning) helper functions and utils such as AwaitAll AwaitAny and Parallel execution mechanism with concurrency limitation.

If there are some concurrency patterns you would like me to implement and there is none available in community or in go lib, you are more than welcome to open an issue.

Listence

MIT

Doc

https://godoc.org/github.com/tempura-shrimp/co

Examples

Parallel

// replace with `co.NewParallel` if no response needed
p := co.NewParallelWithResponse(10) // worker size
for i := 0; i < 10000; i++ {
    i := i
    p.AddWithResponse[int](func() int {
        return i + 1
    })
}

// Wait doesn't indicate a Run, the job will run once added
// So, you could ignore Wait() in some cases
vals := p.Wait()

Awaits

handlers := make([]func() int, 0)
for i := 0; i < 1000; i++ {
    i := i
    handlers = append(handlers, func() int {
        return i + 1
    })
}

responses := co.AwaitAll[int](handlers...)

co's People

Contributors

hypercyberidiot avatar tempura-shrimp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.