gointerop

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package gointerop provides Go concurrency primitive wrappers.

Read-Write Mutexes

  • make-rw-mutex, rw-mutex?
  • rw-mutex-read-lock!, rw-mutex-read-unlock!
  • rw-mutex-write-lock!, rw-mutex-write-unlock!
  • rw-mutex-try-read-lock!, rw-mutex-try-write-lock!

Once

  • make-once, once?
  • once-do!, once-done?

Atomics

  • make-atomic, atomic?
  • atomic-load, atomic-store!, atomic-swap!, atomic-compare-and-swap!

Use Extension or AddToRegistry to register all primitives.

Package gointerop provides Go-specific concurrency primitives.

Index

Constants

This section is empty.

Variables

View Source
var AddToRegistry = Builder.AddToRegistry

AddToRegistry registers all Go interop primitives.

View Source
var Builder = registry.NewRegistryBuilder(addRWMutex, addOnce, addAtomic)

Builder aggregates all Go interop registration functions.

View Source
var Extension = registry.NewDescribedExtension("gointerop",
	"Go concurrency primitives: read-write mutexes, once, atomic boxes.",
	AddToRegistry)

Extension is the Go interop extension.

View Source
var PrimAtomicLoad = helpers.MakeUnaryAccessor(werr.ErrNotAnAtomic, "atomic-load", func(a *values.AtomicBox) values.Value {
	return values.ValueOrVoid(a.Load())
})

PrimAtomicLoad atomically loads the value (atomic-load a) -> value

View Source
var PrimAtomicQ = helpers.MakeTypePredicate(func(o values.Value) bool {
	_, ok := o.(*values.AtomicBox)
	return ok
})

PrimAtomicQ tests if an object is an AtomicBox (atomic? obj) -> boolean

View Source
var PrimAtomicStore = helpers.MakeBinarySetter(werr.ErrNotAnAtomic, "atomic-store!", func(a *values.AtomicBox, val values.Value) {
	a.Store(val)
})

PrimAtomicStore atomically stores a value (atomic-store! a value) -> void

View Source
var PrimOnceDoneQ = helpers.MakeUnaryAccessor(werr.ErrNotAOnce, "once-done?", func(once *values.Once) values.Value {
	return values.BoolToBoolean(once.Done())
})

PrimOnceDoneQ tests if the Once has been executed (once-done? once) -> boolean

View Source
var PrimOnceQ = helpers.MakeTypePredicate(func(o values.Value) bool {
	_, ok := o.(*values.Once)
	return ok
})

PrimOnceQ tests if an object is a Once (once? obj) -> boolean

View Source
var PrimRWMutexQ = helpers.MakeTypePredicate(func(o values.Value) bool {
	_, ok := o.(*values.RWMutex)
	return ok
})

PrimRWMutexQ tests if an object is an RWMutex (rw-mutex? obj) -> boolean

View Source
var PrimRWMutexReadUnlock = helpers.MakeUnarySideEffect(werr.ErrNotARWMutex, "rw-mutex-read-unlock!", func(rwm *values.RWMutex) {
	rwm.RUnlock()
})

PrimRWMutexReadUnlock releases the read lock (rw-mutex-read-unlock! rwm) -> void

View Source
var PrimRWMutexTryReadLock = helpers.MakeUnaryAccessor(werr.ErrNotARWMutex, "rw-mutex-try-read-lock!", func(rwm *values.RWMutex) values.Value {
	return values.BoolToBoolean(rwm.TryRLock())
})

PrimRWMutexTryReadLock tries to acquire the read lock (rw-mutex-try-read-lock! rwm) -> boolean

View Source
var PrimRWMutexTryWriteLock = helpers.MakeUnaryAccessor(werr.ErrNotARWMutex, "rw-mutex-try-write-lock!", func(rwm *values.RWMutex) values.Value {
	return values.BoolToBoolean(rwm.TryLock())
})

PrimRWMutexTryWriteLock tries to acquire the write lock (rw-mutex-try-write-lock! rwm) -> boolean

View Source
var PrimRWMutexWriteUnlock = helpers.MakeUnarySideEffect(werr.ErrNotARWMutex, "rw-mutex-write-unlock!", func(rwm *values.RWMutex) {
	rwm.Unlock()
})

PrimRWMutexWriteUnlock releases the write lock (rw-mutex-write-unlock! rwm) -> void

Functions

func PrimAtomicCompareAndSwap

func PrimAtomicCompareAndSwap(mc machine.CallContext) error

PrimAtomicCompareAndSwap atomically compares and swaps (atomic-compare-and-swap! a old new) -> boolean

func PrimAtomicSwap

func PrimAtomicSwap(mc machine.CallContext) error

PrimAtomicSwap atomically swaps and returns the old value (atomic-swap! a new) -> old

func PrimMakeAtomic

func PrimMakeAtomic(mc machine.CallContext) error

PrimMakeAtomic creates a new AtomicBox value (make-atomic initial) -> atomic

func PrimMakeOnce

func PrimMakeOnce(mc machine.CallContext) error

PrimMakeOnce creates a new Once (make-once) -> once

func PrimMakeRWMutex

func PrimMakeRWMutex(mc machine.CallContext) error

PrimMakeRWMutex creates a new RWMutex (make-rw-mutex [name]) -> rw-mutex

func PrimOnceDo

func PrimOnceDo(cc machine.CallContext) error

PrimOnceDo executes the thunk only once (once-do! once thunk) -> boolean (true if executed, false if already done)

func PrimRWMutexReadLock

func PrimRWMutexReadLock(mc machine.CallContext) error

PrimRWMutexReadLock acquires the read lock, blocking until granted or ctx is cancelled. On cancellation it raises ErrOperationCancelled (with the ErrTimerExpired carve-out); a cancelled acquire never holds the lock. (rw-mutex-read-lock! rwm) -> void

func PrimRWMutexWriteLock

func PrimRWMutexWriteLock(mc machine.CallContext) error

PrimRWMutexWriteLock acquires the write lock, blocking until granted or ctx is cancelled. On cancellation it raises ErrOperationCancelled (with the ErrTimerExpired carve-out); a cancelled acquire never holds the lock. (rw-mutex-write-lock! rwm) -> void

Types

This section is empty.

Jump to

Keyboard shortcuts

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