README

lockfree

GoDoc Build Status Go Report Card codecov

Package lockfree offers lock-free utilities in Go.

Contributing

We would love to have your experiences. Feel free to submit an issue for requesting new implementation or bug report.

License

MIT © Changkun Ou

Expand ▾ Collapse ▴

Documentation

Overview

    Package lockfree offers lock-free utilities

    Index

    Examples

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func AddFloat64

    func AddFloat64(addr *float64, delta float64) (new float64)

      AddFloat64 add delta to given address atomically

      Types

      type Queue

      type Queue struct {
      	// contains filtered or unexported fields
      }

        Queue implements lock-free FIFO freelist based queue. ref: https://dl.acm.org/citation.cfm?doid=248052.248106

        Example
        Output:
        
        1st item
        2nd item
        3rd item
        

        func NewQueue

        func NewQueue() *Queue

          NewQueue creates a new lock-free queue.

          func (*Queue) Dequeue

          func (q *Queue) Dequeue() interface{}

            Dequeue removes and returns the value at the head of the queue. It returns nil if the queue is empty.

            func (*Queue) Enqueue

            func (q *Queue) Enqueue(v interface{})

              Enqueue puts the given value v at the tail of the queue.

              func (*Queue) Length

              func (q *Queue) Length() uint64

                Length returns the length of the queue.

                type Stack

                type Stack struct {
                	// contains filtered or unexported fields
                }

                  Stack implements lock-free freelist based stack.

                  Example
                  Output:
                  
                  3
                  2
                  1
                  

                  func NewStack

                  func NewStack() *Stack

                    NewStack creates a new lock-free queue.

                    func (*Stack) Pop

                    func (s *Stack) Pop() interface{}

                      Pop pops value from the top of the stack.

                      func (*Stack) Push

                      func (s *Stack) Push(v interface{})

                        Push pushes a value on top of the stack.