Skip to content

legendtkl/gpool.v1

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 

This is a goroutine pool

Overview

Features

  1. We will only start a goroutine when needed. That means, we won't start all the goroutines when initializing.
  2. We will adjust the goroutine number dynamically.

How to use

Install

go get github.com/legendtkl/ppl

Example

package main

import (
    "fmt"
    "github.com/legendtkl/pool"
    "time"
)

func main() {
    wp, err := pool.NewLimit(100)
    if err != nil {
        fmt.Println("Create Worker Pool Failed")
    }

    //f()
    for i := 0; i < 100; i++ {
        j := i
        f := func() {
            fmt.Println(j)
        }
        wp.Queue(f)
    }

    time.Sleep(5 * time.Second)
}

Performance

Acknowledge

About

this is a goroutine pool

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages