Opened 16 years ago
Last modified 16 years ago
#37 new enhancement
Add a Worker thread API — at Version 1
| Reported by: | anonymous | Owned by: | becoulet |
|---|---|---|---|
| Priority: | minor | Milestone: | Preemptive scheduler usage |
| Component: | mutek | Keywords: | |
| Cc: |
Description (last modified by )
We sometimes use a worker-thread-like service. Each time it is recreated from scratch. Let's add an API for this.
Here is such a proposal
// Skipped GPCT stuff to declare a queue as "worker_internal".
/**
@this is an item pushable to a worker queue.
*/
struct worker_item_s
{
worker_internal_item_t item;
};
/**
@this permits to retrieve an actual structure from an item
pointer
*/
#define WORKER_ITEM_TO_STRUCT(struct_type, field, item)
/**
@this is a worker function type definition.
Function must return once it handled the reason of wakeup.
*/
typedef void worker_func_t(struct worker_item_s *item, void *priv);
struct worker_thread_s
{
worker_func_t *func;
void *priv;
// lock, queue, whatever
};
/***/
void worker_thread_init(struct worker_thread_s*,
worker_func_t *func,
void *func_priv);
/**
@this runs a context, i.e. this makes the worker ready for wake
up. This does not make function to be called
*/
void worker_thread_start(struct worker_thread_s*);
/**
@this kills the context, but waits for completion of all actions
pending.
*/
void worker_thread_stop(struct worker_thread_s*);
/**
@this makes the worker function to be called once. Multiple
calls to this function yields multiple consecutive calls to
the worker function.
@param item The item to pass to the woken-up function
*/
void worker_thread_wakeup(struct worker_thread_s*, struct worker_item_s *item);
Open questions:
- Allow function to sucide worker context
Change History (1)
comment:1 by , 16 years ago
| Component: | Build system → mutek |
|---|---|
| Description: | modified (diff) |
| Owner: | changed from to |
| Priority: | major → minor |
| Type: | defect → enhancement |
Note:
See TracTickets
for help on using tickets.

