Opened 16 years ago
Last modified 16 years ago
#37 new enhancement
Add a Worker thread API — at Initial Version
| Reported by: | anonymous | Owned by: | Nicolas Pouillon |
|---|---|---|---|
| Priority: | minor | Milestone: | Preemptive scheduler usage |
| Component: | mutek | Keywords: | |
| Cc: |
Description
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
/**
@this is a worker function type definition.
Function must return once it handled the reason of wakeup.
*/
typedef void worker_func_t(void *param);
struct worker_thread_s
{
worker_func_t *func;
void *param;
// lock, whatever
};
/***/
void worker_thread_init(struct worker_thread_s*,
worker_func_t *func,
void *param);
/**
@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.
*/
void worker_thread_wakeup(struct worker_thread_s*);
Open questions:
- Add a void* parameter to wakeup, which would be passed to func ?
- Allow function to sucide context
Note:
See TracTickets
for help on using tickets.

