Tasklet


Object Hierarchy:

Object hierarchy for Tasklet

Description:

public class Tasklet : Object

A Tasklet instance represents a thread that has been spawned to execute a certain function. In order to spawn a thread to execute a method of an object proceed this way: | * prepare a function, or a static method, with the signature void *(*)(void *) | * prepare a struct which will contain: | * the instance of the class which the method is invoked in, | * the parameters (simple types or objects) that will be passed. | * in the function do this: | * cast the void* to a pointer to your struct | * if you pass a ref-counted class, assign it to a local variable in order to increase the refcounter | * if you pass a simple type, assign it to a local variable in order to copy its value | * call Tasklet.schedule_back() in order to let the caller decide when to start the new thread | * call the method with the object and parameters that you just copied in local variables | * when you want to spawn, allocate in the stack a struct of the type | * populate the struct with data | * call Tasklet.spawn(function, &my_struct) The real function/method will not start immediately, but the struct can be safely freed right now.

Features: | * method schedule gives a chance to the scheduler to assign the cpu to other threads; | * method schedule can select a particular tasklet to be scheduled; | * method schedule_back schedules the previous tasklet; | * method join waits for a thread to complete and can get a void* from it; | * ...


Namespace: Ntk.Lib
Package: Netsukuku - vala port

Content:

Properties:

Static methods:

Methods: