Skip to content
/ ring Public

a lock free buffer for multi-producer and single-consumer pattern

License

Notifications You must be signed in to change notification settings

xtracker/ring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ring

a lock free buffer for multi-producer and single-consumer pattern

Usage Example

package main

func main() {
    r := ring.NewRing[int](1000)

    for i := 0; i < 10; i++ {
        go func() {
            r.Offer(1) // concurrent producer
        }()
    }
    
    it := r.Snapshot()
    defer it.Close()
    for v, ok := it.Next(); ok; v, ok = it.Next() {
        // process v
    }
}

About

a lock free buffer for multi-producer and single-consumer pattern

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages