XU XUv0.16.0

#sync/pool

import: #sync/pool

counts: 6 functions, 2 methods, 1 types, 0 constants, 0 method sets

Bounded OS-thread worker pool over pthread + hardware atomics for parallel CPU kernels. Workers never mutate runtime/core allocator or FFI symbol caches: all C symbols are resolved on the creating thread and passed directly via function pointers inside the C state block.

struct ThreadPool

XuAPI
pub struct ThreadPool {

}

Purpose

Pool Connection pool manager scheduling reusable socket connections.

Public fields

This type has no public fields.

cpu_count

XuAPI
pub fn cpu_count() int

Purpose

Query online OS hardware threads (clamped to [1, 256]); 1 on unsupported OS.

Parameters

No arguments are required.

Returns

int — a value of this type

empty_thread_pool

XuAPI
pub fn empty_thread_pool() ThreadPool

Purpose

Empty thread pool.

Parameters

No arguments are required.

Returns

ThreadPool — a value of this type

new_thread_pool

XuAPI
pub fn new_thread_pool(num_threads int) ThreadPool

Purpose

Construct thread pool.

Parameters

num_threads int
num_threads (int)

Returns

ThreadPool — a value of this type

(&ThreadPool) num_threads

XuAPI
pub fn (p &ThreadPool) num_threads() int

Purpose

Operation on &ThreadPool: num threads.

Parameters

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

Returns

int — a value of this type

($&ThreadPool) close

XuAPI
pub fn (p $&ThreadPool) close()

Purpose

Operation on $&ThreadPool: close the resource.

Parameters

p $&ThreadPool
The ThreadPool instance used by this call (exclusive borrow).

Returns

This call does not return a value.

max_procs

XuAPI
pub fn max_procs() int

Purpose

Current maximum number of OS threads executing xu green threads.

Parameters

No arguments are required.

Returns

int — a value of this type

set_max_procs

XuAPI
pub fn set_max_procs(nprocs int) int

Purpose

Enable M:N work-sharing execution of xu green threads across n OS threads. When n <= 0, honors XU_PROCS if set, otherwise uses cpu_count.

Parameters

nprocs int
nprocs (int)

Returns

int — a value of this type

stop_scheduler

XuAPI
pub fn stop_scheduler()

Purpose

Gracefully stop and join background M:N worker OS threads.

Parameters

No arguments are required.

Returns

This call does not return a value.