freesync

package module
v0.0.0-...-ac341bb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2022 License: BSD-3-Clause Imports: 3 Imported by: 1

README

freesync

Go Reference

Concurrency safety data structures and algorithms based on lock-free.

本项目包含两个部分,freesyn/lockfree为一套无锁的基础数据结构。freesync为一套基于无锁基础数据结构的简单复合结构。

目录

结构 说明 性能
freesync/lockfree LimitedSlice 无锁的长度受限的Slice
freesync/lockfree SinglyLinkedList 无锁的单链表
freesync/lockfree Slice 无锁的支持增长的Slice
freesync Slice 并发安全的Slice 与官方slice+mutex相比,写性能提升一半,读性能提升百倍左右
freesync Bag 并发安全的容器 与sync.Map相比,写性能提升一半左右

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bag

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

Bag 并发安全的容量。

func NewBag

func NewBag() *Bag

NewBag 新建一个Bag。

func (*Bag) Add

func (bag *Bag) Add(p interface{}) int

Add 添加一个元素,返回索引。 警告:删除元素的索引会被重用。

func (*Bag) DeleteAt

func (bag *Bag) DeleteAt(index int)

DeleteAt 删除指定位置上的元素。 警告:删除后,index会被回收重用。

func (*Bag) Length

func (bag *Bag) Length() int

Length 长度。

func (*Bag) Range

func (bag *Bag) Range(f func(index int, p interface{}) (stopIteration bool))

Range 基于索引顺序的遍历。

type Slice

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

Slice 并发安全的Slice结构。

func (*Slice) Append

func (slice *Slice) Append(p interface{}) int

Append 在末尾追加一个元素。返回下标。

func (*Slice) Length

func (slice *Slice) Length() int

Length 长度。

func (*Slice) Load

func (slice *Slice) Load(index int) interface{}

Load 取得下标位置上的值。

func (*Slice) Range

func (slice *Slice) Range(f func(index int, p interface{}) (stopIteration bool))

Range 遍历。

func (*Slice) UpdateAt

func (slice *Slice) UpdateAt(index int, p interface{}) (old interface{})

UpdateAt 更新下标位置上的值,返回旧值。

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL