EgretDoc
Back to Home
Location:system/concurrent.job_queue

Module

Module documentation.

moduleconcurrent.job_queue

Classes

Classes and inheritance.

classconcurrent.job_queue::Job
@brief`Job` type.
@details`Job` encapsulates state and operations exported by the system module. It commonly stores runtime handles, protocol state, buffers, configuration, or collection data. Its methods define the primary behavior for the type. If the type owns external resources, prefer `dispose` or `close` for deterministic release.
class Job {
    /*
    @brief `f` field.
classconcurrent.job_queue::JobQueue
@brief`JobQueue` type.
@details`JobQueue` encapsulates state and operations exported by the system module. It commonly stores runtime handles, protocol state, buffers, configuration, or collection data. Its methods define the primary behavior for the type. If the type owns external resources, prefer `dispose` or `close` for deterministic release.
class JobQueue {
    /*
    @brief `mu` field.

Functions

Free functions and class methods.

functionconcurrent.job_queue::noop_job
Signaturefunc noop_job(arg: Any) -> Int
func noop_job(arg: Any) -> Int {
    return 0;
}
@briefProvides the system library operation `noop_job`.
@detailsExecutes the `noop_job` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • argOpaque argument value passed through to a callback, thread entry point, or runtime helper.
@returnReturns the operation result as `Int`.
functionconcurrent.job_queue::Job.init
Signaturefunc init(self: concurrent.job_queue.Job, f: (Any) -> Int, arg: Any) -> Void
    func init(self: concurrent.job_queue.Job, f: (Any) -> Int, arg: Any) -> Void {
        self.f = f;
        self.arg = arg;
@briefInitializes a `Job` instance.
@detailsEstablishes the initial field state for `Job` so other methods can be called safely. Constructor logic should keep fields consistent and avoid leaking partially initialized resources.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
  • fFuture, callback, file handle, or function object that the operation observes or invokes.
  • argOpaque argument value passed through to a callback, thread entry point, or runtime helper.
@returnVoid
functionconcurrent.job_queue::Job.deinit
Signaturefunc deinit(self: concurrent.job_queue.Job) -> Void
    func deinit(self: concurrent.job_queue.Job) -> Void {
        _ = self.release_wait_resources();
    }
@briefReleases fallback resources at the end of the `Job` lifetime.
@detailsThis destructor hook is called by object lifetime management to clean up underlying resources that were not released explicitly. Normal application code should prefer `dispose`, `close`, or the module-specific close function to release resources at a deterministic time.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionconcurrent.job_queue::Job.attach_wait_group
Signaturefunc attach_wait_group(self: concurrent.job_queue.Job, wg: sync.WaitGroup) -> Void
    func attach_wait_group(self: concurrent.job_queue.Job, wg: sync.WaitGroup) -> Void {
        self.has_wg = true;
        self.wg = wg;
@briefProvides the system library operation `Job.attach_wait_group`.
@detailsExecutes the `attach_wait_group` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
  • wgWait-group object used to synchronize concurrent work.
@returnVoid
functionconcurrent.job_queue::Job.mark_stop
Signaturefunc mark_stop(self: concurrent.job_queue.Job) -> Void
    func mark_stop(self: concurrent.job_queue.Job) -> Void {
        self.stop = true;
    }
@briefProvides the system library operation `Job.mark_stop`.
@detailsExecutes the `mark_stop` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionconcurrent.job_queue::Job.detach
Signaturefunc detach(self: concurrent.job_queue.Job) -> Void
    func detach(self: concurrent.job_queue.Job) -> Void {
        if self.detached {
            return;
@briefProvides the system library operation `Job.detach`.
@detailsExecutes the `detach` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionconcurrent.job_queue::Job.complete
Signaturefunc complete(self: concurrent.job_queue.Job, result: Int) -> Void
    func complete(self: concurrent.job_queue.Job, result: Int) -> Void {
        _ = self.mu.lock();
        _ = self.result.store(result);
@briefProvides the system library operation `Job.complete`.
@detailsExecutes the `complete` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
  • resultResult value or result container populated by the operation.
@returnVoid
functionconcurrent.job_queue::Job.run_and_complete
Signaturefunc run_and_complete(self: concurrent.job_queue.Job) -> Int
    func run_and_complete(self: concurrent.job_queue.Job) -> Int {
        let should_detached: Bool = self.detached;
        let should_stop: Bool = self.stop;
@briefProvides the system library operation `Job.run_and_complete`.
@detailsExecutes the `run_and_complete` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns the operation result as `Int`.
functionconcurrent.job_queue::Job.wait
Signaturefunc wait(self: concurrent.job_queue.Job) -> Int
    func wait(self: concurrent.job_queue.Job) -> Int {
        _ = self.mu.lock();
        loop (; self.done.load() == 0; ) {
@briefProvides the system library operation `Job.wait`.
@detailsExecutes the `wait` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns the operation result as `Int`.
functionconcurrent.job_queue::Job.free
Signaturefunc free(self: concurrent.job_queue.Job) -> Void
    func free(self: concurrent.job_queue.Job) -> Void {
        if self.freed || self.done.load() == 0 {
            return;
@briefProvides the system library operation `Job.free`.
@detailsExecutes the `free` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionconcurrent.job_queue::Job.dispose
Signaturefunc dispose(self: concurrent.job_queue.Job) -> Void
    func dispose(self: concurrent.job_queue.Job) -> Void {
        _ = self.free();
    }
@briefExplicitly releases resources owned by `Job`.
@detailsThis method deterministically cleans up file descriptors, network connections, native handles, buffers, or other external resources. Implementations should be idempotent where possible, and repeated calls must not corrupt object state.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionconcurrent.job_queue::Job.cancel
Signaturefunc cancel(self: concurrent.job_queue.Job) -> Void
    func cancel(self: concurrent.job_queue.Job) -> Void {
        if self.detached {
            _ = self.free();
@briefProvides the system library operation `Job.cancel`.
@detailsExecutes the `cancel` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionconcurrent.job_queue::Job.release_wait_resources
Signaturefunc release_wait_resources(self: concurrent.job_queue.Job) -> Void
    func release_wait_resources(self: concurrent.job_queue.Job) -> Void {
        if self.freed {
            return;
@briefProvides the system library operation `Job.release_wait_resources`.
@detailsExecutes the `release_wait_resources` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionconcurrent.job_queue::JobQueue.init
Signaturefunc init(self: concurrent.job_queue.JobQueue, capacity: Int) -> Void
    func init(self: concurrent.job_queue.JobQueue, capacity: Int) -> Void {
        self.mu = new sync.Mutex();
        self.cv_not_empty = new sync.CondVar();
@briefInitializes a `JobQueue` instance.
@detailsEstablishes the initial field state for `JobQueue` so other methods can be called safely. Constructor logic should keep fields consistent and avoid leaking partially initialized resources.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
  • capacityRequested storage capacity for the created or resized container.
@returnVoid
functionconcurrent.job_queue::JobQueue.push
Signaturefunc push(self: concurrent.job_queue.JobQueue, job: concurrent.job_queue.Job) -> Bool
    func push(self: concurrent.job_queue.JobQueue, job: concurrent.job_queue.Job) -> Bool {
        _ = self.mu.lock();
        loop (; !self.closed && self.capacity > 0 && self.queue.len() >= self.capacity; ) {
@briefAppends an element with `JobQueue.push`.
@detailsExecutes the `push` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
  • jobJob object or job callback scheduled for execution.
@returnReturns a boolean result; true means the condition holds or the operation succeeded.
functionconcurrent.job_queue::JobQueue.pop
Signaturefunc pop(self: concurrent.job_queue.JobQueue) -> concurrent.job_queue.Job?
    func pop(self: concurrent.job_queue.JobQueue) -> concurrent.job_queue.Job? {
        let def: concurrent.job_queue.Job = new concurrent.job_queue.Job(noop_job, 0);
        _ = def.mark_stop();
@briefPops an element with `JobQueue.pop`.
@detailsExecutes the `pop` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns the operation result as `concurrent.job_queue.Job?`.
functionconcurrent.job_queue::JobQueue.pop_or
Signaturefunc pop_or(self: concurrent.job_queue.JobQueue, def: concurrent.job_queue.Job) -> concurrent.job_queue.Job
    func pop_or(self: concurrent.job_queue.JobQueue, def: concurrent.job_queue.Job) -> concurrent.job_queue.Job {
        _ = self.mu.lock();
        loop (; !self.closed && self.queue.len() <= 0; ) {
@briefProvides the system library operation `JobQueue.pop_or`.
@detailsExecutes the `pop_or` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
  • defDefault value returned or used when the requested value is absent, invalid, or cannot be decoded.
@returnReturns the operation result as `concurrent.job_queue.Job`.
functionconcurrent.job_queue::JobQueue.close
Signaturefunc close(self: concurrent.job_queue.JobQueue) -> Void
    func close(self: concurrent.job_queue.JobQueue) -> Void {
        _ = self.mu.lock();
        self.closed = true;
@briefCloses resources and makes later operations unavailable with `JobQueue.close`.
@detailsExecutes the `close` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionconcurrent.job_queue::JobQueue.drain_unrooted
Signaturefunc drain_unrooted(self: concurrent.job_queue.JobQueue) -> Void
    func drain_unrooted(self: concurrent.job_queue.JobQueue) -> Void {
        let def: concurrent.job_queue.Job = new concurrent.job_queue.Job(noop_job, 0);
        _ = def.mark_stop();
@briefProvides the system library operation `JobQueue.drain_unrooted`.
@detailsExecutes the `drain_unrooted` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionconcurrent.job_queue::JobQueue.free
Signaturefunc free(self: concurrent.job_queue.JobQueue) -> Void
    func free(self: concurrent.job_queue.JobQueue) -> Void {
        if self.freed {
            return;
@briefProvides the system library operation `JobQueue.free`.
@detailsExecutes the `free` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionconcurrent.job_queue::JobQueue.dispose
Signaturefunc dispose(self: concurrent.job_queue.JobQueue) -> Void
    func dispose(self: concurrent.job_queue.JobQueue) -> Void {
        _ = self.free();
    }
@briefExplicitly releases resources owned by `JobQueue`.
@detailsThis method deterministically cleans up file descriptors, network connections, native handles, buffers, or other external resources. Implementations should be idempotent where possible, and repeated calls must not corrupt object state.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionconcurrent.job_queue::JobQueue.deinit
Signaturefunc deinit(self: concurrent.job_queue.JobQueue) -> Void
    func deinit(self: concurrent.job_queue.JobQueue) -> Void {
        _ = self.free();
    }
@briefReleases fallback resources at the end of the `JobQueue` lifetime.
@detailsThis destructor hook is called by object lifetime management to clean up underlying resources that were not released explicitly. Normal application code should prefer `dispose`, `close`, or the module-specific close function to release resources at a deterministic time.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionconcurrent.job_queue::JobQueue.len
Signaturefunc len(self: concurrent.job_queue.JobQueue) -> Int
    func len(self: concurrent.job_queue.JobQueue) -> Int {
        _ = self.mu.lock();
        let n: Int = self.queue.len();
@briefReturns the element count or byte length with `JobQueue.len`.
@detailsExecutes the `len` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns the operation result as `Int`.
functionconcurrent.job_queue::JobQueue.is_closed
Signaturefunc is_closed(self: concurrent.job_queue.JobQueue) -> Bool
    func is_closed(self: concurrent.job_queue.JobQueue) -> Bool {
        _ = self.mu.lock();
        let c: Bool = self.closed;
@briefTests whether the state satisfies the condition represented by `JobQueue.is_closed`.
@detailsExecutes the `is_closed` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns a boolean result; true means the condition holds or the operation succeeded.

Variables

Class fields (var).

varconcurrent.job_queue::Job.f
Type(Any) -> Int
@brief`f` field.
@detailsHolds the `f` value for each `Job` instance. The field type is `(Any) -> Int`, and constructors and methods keep it synchronized with the object's runtime state.
    var f: (Any) -> Int;
    /*
    @brief `arg` field.
varconcurrent.job_queue::Job.arg
TypeAny
@brief`arg` field.
@detailsHolds the `arg` value for each `Job` instance. The field type is `Any`, and constructors and methods keep it synchronized with the object's runtime state.
    var arg: Any;
    /*
    @brief `result` field.
varconcurrent.job_queue::Job.result
Typesync.Int64
@brief`result` field.
@detailsHolds the `result` value for each `Job` instance. The field type is `sync.Int64`, and constructors and methods keep it synchronized with the object's runtime state.
    var result: sync.Int64;
    /*
    @brief `done` field.
varconcurrent.job_queue::Job.done
Typesync.Int64
@brief`done` field.
@detailsHolds the `done` value for each `Job` instance. The field type is `sync.Int64`, and constructors and methods keep it synchronized with the object's runtime state.
    var done: sync.Int64;
    /*
    @brief `stop` field.
varconcurrent.job_queue::Job.stop
TypeBool
@brief`stop` field.
@detailsHolds the `stop` value for each `Job` instance. The field type is `Bool`, and constructors and methods keep it synchronized with the object's runtime state.
    var stop: Bool;
    /*
    @brief `detached` field.
varconcurrent.job_queue::Job.detached
TypeBool
@brief`detached` field.
@detailsHolds the `detached` value for each `Job` instance. The field type is `Bool`, and constructors and methods keep it synchronized with the object's runtime state.
    var detached: Bool;
    /*
    @brief `freed` field.
varconcurrent.job_queue::Job.freed
TypeBool
@brief`freed` field.
@detailsHolds the `freed` value for each `Job` instance. The field type is `Bool`, and constructors and methods keep it synchronized with the object's runtime state.
    var freed: Bool;
    /*
    @brief `has_wg` field.
varconcurrent.job_queue::Job.has_wg
TypeBool
@brief`has_wg` field.
@detailsHolds the `has_wg` value for each `Job` instance. The field type is `Bool`, and constructors and methods keep it synchronized with the object's runtime state.
    var has_wg: Bool;
    /*
    @brief `wg` field.
varconcurrent.job_queue::Job.wg
Typesync.WaitGroup?
@brief`wg` field.
@detailsHolds the `wg` value for each `Job` instance. The field type is `sync.WaitGroup?`, and constructors and methods keep it synchronized with the object's runtime state.
    var wg: sync.WaitGroup?;
    /*
    @brief `mu` field.
varconcurrent.job_queue::Job.mu
Typesync.Mutex
@brief`mu` field.
@detailsHolds the `mu` value for each `Job` instance. The field type is `sync.Mutex`, and constructors and methods keep it synchronized with the object's runtime state.
    var mu: sync.Mutex;
    /*
    @brief `cv` field.
varconcurrent.job_queue::Job.cv
Typesync.CondVar
@brief`cv` field.
@detailsHolds the `cv` value for each `Job` instance. The field type is `sync.CondVar`, and constructors and methods keep it synchronized with the object's runtime state.
    var cv: sync.CondVar;

    /*
varconcurrent.job_queue::JobQueue.mu
Typesync.Mutex
@brief`mu` field.
@detailsHolds the `mu` value for each `JobQueue` instance. The field type is `sync.Mutex`, and constructors and methods keep it synchronized with the object's runtime state.
    var mu: sync.Mutex;
    /*
    @brief `cv` field.
varconcurrent.job_queue::JobQueue.cv_not_empty
Typesync.CondVar
@brief`cv_not_empty` field.
@detailsHolds the `cv_not_empty` value for each `JobQueue` instance. The field type is `sync.CondVar`, and constructors and methods keep it synchronized with the object's runtime state.
    var cv_not_empty: sync.CondVar;
    /*
    @brief `cv_not_full` field.
varconcurrent.job_queue::JobQueue.cv_not_full
Typesync.CondVar
@brief`cv_not_full` field.
@detailsHolds the `cv_not_full` value for each `JobQueue` instance. The field type is `sync.CondVar`, and constructors and methods keep it synchronized with the object's runtime state.
    var cv_not_full: sync.CondVar;
    /*
    @brief `queue` field.
varconcurrent.job_queue::JobQueue.queue
Typecollections.Queue<concurrent.job_queue.Job>
@brief`queue` field.
@detailsHolds the `queue` value for each `JobQueue` instance. The field type is `collections.Queue<concurrent.job_queue.Job>`, and constructors and methods keep it synchronized with the object's runtime state.
    var queue: collections.Queue<concurrent.job_queue.Job>;
    /*
    @brief `capacity` field.
varconcurrent.job_queue::JobQueue.capacity
TypeInt
@brief`capacity` field.
@detailsStores the capacity. The field type is `Int`, and it is maintained by the constructors and methods of `JobQueue`.
    var capacity: Int;
    /*
    @brief `closed` field.
varconcurrent.job_queue::JobQueue.closed
TypeBool
@brief`closed` field.
@detailsIndicates whether the resource has already been closed. The field type is `Bool`, and it is maintained by the constructors and methods of `JobQueue`.
    var closed: Bool;
    /*
    @brief `freed` field.
varconcurrent.job_queue::JobQueue.freed
TypeBool
@brief`freed` field.
@detailsHolds the `freed` value for each `JobQueue` instance. The field type is `Bool`, and constructors and methods keep it synchronized with the object's runtime state.
    var freed: Bool;
    /*
    @brief `has_wg` field.