XU XUv0.16.0

#sync

import: #sync

counts: 11 functions, 25 methods, 10 types, 0 constants, 0 method sets

Mutex / WaitGroup / Once / RWMutex / Cond and atomic int.

struct Mutex

XuAPI
pub struct Mutex {
    pub tok chan int
}

Purpose

Structure encapsulating tok.

Public fields

tok chan int
field (channel; type chan int)

struct WaitGroup

XuAPI
pub struct WaitGroup {

}

Purpose

WaitGroup context or state structure.

Public fields

This type has no public fields.

mutex

XuAPI
pub fn mutex() Mutex

Purpose

Construct a mutual exclusion lock synchronization primitive.

Parameters

No arguments are required.

Returns

Mutex — a value of this type

($&Mutex) lock

XuAPI
pub fn (m $&Mutex) lock()

Purpose

Operation on $&Mutex: acquire the lock.

Parameters

m $&Mutex
The Mutex instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&Mutex) unlock

XuAPI
pub fn (m $&Mutex) unlock()

Purpose

Operation on $&Mutex: release the lock.

Parameters

m $&Mutex
The Mutex instance used by this call (exclusive borrow).

Returns

This call does not return a value.

wait_group

XuAPI
pub fn wait_group() WaitGroup

Purpose

Wait group.

Parameters

No arguments are required.

Returns

WaitGroup — a value of this type

($&WaitGroup) add

XuAPI
pub fn (w $&WaitGroup) add(delta int)

Purpose

Operation on $&WaitGroup: add.

Parameters

w $&WaitGroup
The WaitGroup instance used by this call (exclusive borrow).
delta int
delta (int)

Returns

This call does not return a value.

($&WaitGroup) done

XuAPI
pub fn (w $&WaitGroup) done()

Purpose

Execute done on $&WaitGroup.

Parameters

w $&WaitGroup
The WaitGroup instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&WaitGroup) wait

XuAPI
pub fn (w $&WaitGroup) wait(n int)

Purpose

Execute wait on $&WaitGroup.

Parameters

w $&WaitGroup
The WaitGroup instance used by this call (exclusive borrow).
n int
count, length, or limit (int)

Returns

This call does not return a value.

($&WaitGroup) wait_pending

XuAPI
pub fn (w $&WaitGroup) wait_pending()

Purpose

Operation on $&WaitGroup: wait pending.

Parameters

w $&WaitGroup
The WaitGroup instance used by this call (exclusive borrow).

Returns

This call does not return a value.

load_int

XuAPI
pub fn load_int(x $&int) int

Purpose

Load int.

Parameters

x $&int
value (exclusive borrow; may modify the original; type $&int)

Returns

int — a value of this type

store_int

XuAPI
pub fn store_int(x $&int, v int)

Purpose

Store int.

Parameters

x $&int
value (exclusive borrow; may modify the original; type $&int)
v int
value (int)

Returns

This call does not return a value.

add_int

XuAPI
pub fn add_int(x $&int, d int) int

Purpose

Add int.

Parameters

x $&int
value (exclusive borrow; may modify the original; type $&int)
d int
d (int)

Returns

int — a value of this type

compare_and_swap_int

XuAPI
pub fn compare_and_swap_int(x $&int, old int, new int) bool

Purpose

Compare and swap int.

Parameters

x $&int
value (exclusive borrow; may modify the original; type $&int)
old int
old value / piece to replace (int)
new int
new value / replacement (int)

Returns

bool — true or false

struct Once

XuAPI
pub struct Once {
    pub mu Mutex
}

Purpose

Structure encapsulating mu.

Public fields

mu Mutex
field (Mutex)

once

XuAPI
pub fn once() Once

Purpose

Execute once.

Parameters

No arguments are required.

Returns

Once — a value of this type

($&Once) first_time

XuAPI
pub fn (o $&Once) first_time() bool

Purpose

Operation on $&Once: first time.

Parameters

o $&Once
The Once instance used by this call (exclusive borrow).

Returns

bool — true or false

($&Once) do

XuAPI
pub fn (o $&Once) do(f fn())

Purpose

Execute do on $&Once.

Parameters

o $&Once
The Once instance used by this call (exclusive borrow).
f fn()
Callback with signature fn(); pass the function value for this operation to invoke.

Returns

This call does not return a value.

struct RWMutex

XuAPI
pub struct RWMutex {
    pub w Mutex
    pub writer_sem chan int
    pub reader_sem chan int
}

Purpose

Structure encapsulating w, writer_sem, reader_sem.

Public fields

w Mutex
writer or width
writer_sem chan int
field (channel; type chan int)
reader_sem chan int
field (channel; type chan int)

rw_mutex

XuAPI
pub fn rw_mutex() RWMutex

Purpose

Construct a new RWMutex.

Parameters

No arguments are required.

Returns

RWMutex — a value of this type

($&RWMutex) close

XuAPI
pub fn (m $&RWMutex) close()

Purpose

Operation on $&RWMutex: close the resource.

Parameters

m $&RWMutex
The RWMutex instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&RWMutex) read_lock

XuAPI
pub fn (m $&RWMutex) read_lock()

Purpose

Operation on $&RWMutex: acquire a shared read lock.

Parameters

m $&RWMutex
The RWMutex instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&RWMutex) read_unlock

XuAPI
pub fn (m $&RWMutex) read_unlock()

Purpose

Operation on $&RWMutex: release a read lock.

Parameters

m $&RWMutex
The RWMutex instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&RWMutex) write_lock

XuAPI
pub fn (m $&RWMutex) write_lock()

Purpose

Operation on $&RWMutex: acquire an exclusive write lock.

Parameters

m $&RWMutex
The RWMutex instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&RWMutex) write_unlock

XuAPI
pub fn (m $&RWMutex) write_unlock()

Purpose

Operation on $&RWMutex: release a write lock.

Parameters

m $&RWMutex
The RWMutex instance used by this call (exclusive borrow).

Returns

This call does not return a value.

struct CondState

XuAPI
pub struct CondState {
    pub waiters []chan int
    pub head int
}

Purpose

Structure encapsulating waiters, head.

Public fields

waiters []chan int
field ([]chan int)
head int
field (int)

struct Cond

XuAPI
pub struct Cond {
    pub state chan CondState
}

Purpose

Structure encapsulating state.

Public fields

state chan CondState
field (channel; type chan CondState)

cond

XuAPI
pub fn cond() Cond

Purpose

Execute cond.

Parameters

No arguments are required.

Returns

Cond — a value of this type

($&Cond) wait

XuAPI
pub fn (c $&Cond) wait(m $&Mutex)

Purpose

Execute wait on $&Cond.

Parameters

c $&Cond
The Cond instance used by this call (exclusive borrow).
m $&Mutex
m (exclusive borrow; may modify the original; type $&Mutex)

Returns

This call does not return a value.

($&Cond) signal

XuAPI
pub fn (c $&Cond) signal()

Purpose

Execute signal on $&Cond.

Parameters

c $&Cond
The Cond instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&Cond) broadcast

XuAPI
pub fn (c $&Cond) broadcast()

Purpose

Execute broadcast on $&Cond.

Parameters

c $&Cond
The Cond instance used by this call (exclusive borrow).

Returns

This call does not return a value.

struct MapVal

XuAPI
pub struct MapVal {
    pub value string
    pub found bool
}

Purpose

Structure encapsulating value, found.

Public fields

value string
field (string)
found bool
field (bool)

struct MapEntry

XuAPI
pub struct MapEntry {
    pub key string
    pub val string
    pub active bool
}

Purpose

Structure encapsulating key, val, active.

Public fields

key string
key
val string
value
active bool
field (bool)

struct Map

XuAPI
pub struct Map {
    pub mu RWMutex
}

Purpose

Structure encapsulating mu.

Public fields

mu RWMutex
field (RWMutex)

sync_map

XuAPI
pub fn sync_map() Map

Purpose

Sync map.

Parameters

No arguments are required.

Returns

Map — a value of this type

($&Map) close

XuAPI
pub fn (m $&Map) close()

Purpose

Operation on $&Map: close the resource.

Parameters

m $&Map
The Map instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&Map) load

XuAPI
pub fn (m $&Map) load(key &string) MapVal

Purpose

Execute load on $&Map.

Parameters

m $&Map
The Map instance used by this call (exclusive borrow).
key &string
key (read-only borrow; caller keeps the original; type &string)

Returns

MapVal — a value of this type

($&Map) store

XuAPI
pub fn (m $&Map) store(key string, val string)

Purpose

Execute store on $&Map.

Parameters

m $&Map
The Map instance used by this call (exclusive borrow).
key string
key (string)
val string
value (string)

Returns

This call does not return a value.

($&Map) delete

XuAPI
pub fn (m $&Map) delete(key &string)

Purpose

Execute delete on $&Map.

Parameters

m $&Map
The Map instance used by this call (exclusive borrow).
key &string
key (read-only borrow; caller keeps the original; type &string)

Returns

This call does not return a value.

($&Map) load_or_store

XuAPI
pub fn (m $&Map) load_or_store(key string, val string) MapVal

Purpose

Operation on $&Map: load or store.

Parameters

m $&Map
The Map instance used by this call (exclusive borrow).
key string
key (string)
val string
value (string)

Returns

MapVal — a value of this type

($&Map) load_and_delete

XuAPI
pub fn (m $&Map) load_and_delete(key &string) MapVal

Purpose

Operation on $&Map: load and delete.

Parameters

m $&Map
The Map instance used by this call (exclusive borrow).
key &string
key (read-only borrow; caller keeps the original; type &string)

Returns

MapVal — a value of this type

($&Map) len

XuAPI
pub fn (m $&Map) len() int

Purpose

Operation on $&Map: return the length.

Parameters

m $&Map
The Map instance used by this call (exclusive borrow).

Returns

int — a value of this type

struct Pool

XuAPI
pub struct Pool {
    pub ch chan string
}

Purpose

Sync Connection pool manager scheduling reusable socket connections.

Public fields

ch chan string
character code

pool

XuAPI
pub fn pool(capacity int) Pool

Purpose

Execute pool.

Parameters

capacity int
capacity (int)

Returns

Pool — a value of this type

(&Pool) put

XuAPI
pub fn (p &Pool) put(val string)

Purpose

Store or update the value associated with the specified key.

Parameters

p &Pool
The Pool instance used by this call (borrow).
val string
value (string)

Returns

This call does not return a value.

(&Pool) get

XuAPI
pub fn (p &Pool) get() MapVal

Purpose

Execute get on &Pool.

Parameters

p &Pool
The Pool instance used by this call (borrow).

Returns

MapVal — a value of this type