﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	resolution	keywords	cc
37	Add a Worker thread API	anonymous	Nicolas Pouillon	"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

{{{
#!c

/**
 @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
"	defect	new	major		Build system			
