NAME ^

src/pmc/scheduler.pmc - The concurrency scheduler

DESCRIPTION ^

Implements the core concurrency scheduler.

Vtable Functions ^

void init()

Initialize a concurrency scheduler object.

void init_pmc(PMC *data)

Initializes a new Scheduler with a Hash PMC with any or all of the keys:

id

An Integer representing the unique identifier for this scheduler.

*/

    void init_pmc(PMC *data) {
        PMC              *elem;
        Parrot_Scheduler *core_struct;

        if (! VTABLE_isa(INTERP, data, CONST_STRING(INTERP, "Hash")))
            real_exception(INTERP, NULL, INVALID_OPERATION,
                "Scheduler initializer must be a Hash");

        SELF.init();
        core_struct = PARROT_SCHEDULER(SELF);

        elem = VTABLE_get_pmc_keyed_str(INTERP, data, CONST_STRING(INTERP, "id"));

        if (! PMC_IS_NULL(elem))
            core_struct->id      = VTABLE_get_integer(INTERP, elem);
    }
/*

void push_pmc(PMC *value)

Insert a task into the task list, giving it a task ID one higher than the current maximum, and a birthtime of the current time.

PMC *pop_pmc()

Retrieve the next task from the task list. If the task index is invalid, recalculate it before retrieving the next task.

INTVAL get_integer()

Retrieve the number of pending tasks in the scheduler's task list.

void delete_keyed_int(INTVAL key)

Removes the task with the given task ID from the task list.

PMC *share_ro()

Set this PMC as shared.

void destroy()

Free the scheduler's underlying struct.

void mark()

Mark any referenced strings and PMCs.

void visit(visit_info *info)

This is used by freeze/thaw to visit the contents of the scheduler.

*info is the visit info, (see include/parrot/pmc_freeze.h).

void freeze(visit_info *info)

Used to archive the scheduler.

void thaw(visit_info *info)

Used to unarchive the scheduler.

void thawfinish(visit_info *info)

Called after the scheduler has been thawed.

Methods ^

PCCMETHOD add_handler(PMC *handler)

Add a handler to the scheduler.

PCCMETHOD find_handler(PMC *task)

Search for a handler for the given task. If no handler is found, return PMCNULL.

SEE ALSO ^

docs/pdds/pdd25_concurrency.pod.


parrot