No description
This repository has been archived on 2024-06-28. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
Find a file
2024-01-20 00:29:09 +08:00
clock.go feat: initial commit 2024-01-01 20:00:48 +08:00
errors.go feat: initial commit 2024-01-01 20:00:48 +08:00
go.mod feat: initial commit 2024-01-01 20:00:48 +08:00
go.sum feat: initial commit 2024-01-01 20:00:48 +08:00
LICENSE feat: initial commit 2024-01-01 20:00:48 +08:00
lock.go feat: initial commit 2024-01-01 20:00:48 +08:00
README.md feat: initial commit 2024-01-01 20:00:48 +08:00
tl2.go refactor: remove unnecessary return value 2024-01-20 00:29:09 +08:00
tl2_test.go refactor: remove unnecessary return value 2024-01-20 00:29:09 +08:00

Software Transactional Memory

This implementation is based on the paper: Transactional Locking II - D Dice.

cnt := stm.NewTVar(0)
new, err := stm.Atomically(func(tx *stm.Tx) (any, error) {
    old, err := cnt.Load(tx)
    if err != nil {
        return nil, err
    }
    new := old.(int) + 1
    cnt.Store(tx, new)
    return new, nil
})

See tl2_test.go for more examples.