Skip to content

jackal-xmpp/runqueue

Repository files navigation

runqueue

Build Status Go Report Card Coverage Godoc Releases LICENSE

Installation

go get -u github.com/jackal-xmpp/runqueue/v2

Usage

The runqueue package allows to enqueue and run functions in serial order ensuring exclusive access.

Example

package main 

import (
    "fmt"
    "log"

    "github.com/jackal-xmpp/runqueue/v2"
)

func main() {
    rq := runqueue.New("rq-1", log.Printf)

    var counter int32
    for i := 0; i < 2500; i++ {
        rq.Run(func() { counter++ })
    }
    fmt.Println(counter)
}

Expected output:

2500

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

License

Apache License 2.0