1
/***********************************************************************/
5
/* Contributed by Sylvain Le Gall for Lexifi */
7
/* Copyright 2008 Institut National de Recherche en Informatique et */
8
/* en Automatique. All rights reserved. This file is distributed */
9
/* under the terms of the GNU Library General Public License, with */
10
/* the special exception on linking described in file ../../LICENSE. */
12
/***********************************************************************/
14
/* $Id: winworker.h,v 1.2 2008/07/31 12:09:18 xleroy Exp $ */
18
#define _WIN32_WINNT 0x0400
21
/* Pool of worker threads.
23
* These functions help to manage a pool of worker thread and submit task to
24
* the pool. It helps to reduce the number of thread creation.
26
* Each worker are started in alertable wait state and jobs are submitted as
27
* APC (asynchronous procedure call).
30
/* Data associated with submitted job */
31
typedef struct _WORKER WORKER;
32
typedef WORKER *LPWORKER;
34
/* Function type of submitted job:
35
* void worker_call (HANDLE hStop, void *data)
37
* This function will be called using the data following:
38
* - hStop must be watched for change, since it represents an external command
39
* to stop the call. This event is shared through the WORKER structure, which
40
* can be access throuhg worker_job_event_done.
41
* - data is user provided data for the function.
43
typedef void (*WORKERFUNC) (HANDLE, void *);
45
/* Initialize global data structure for worker
47
void worker_init (void);
49
/* Free global data structure for worker
51
void worker_cleanup (void);
53
/* Submit a job to worker. Use returned data to synchronize with the procedure
56
LPWORKER worker_job_submit (WORKERFUNC f, void *data);
58
/* Get event to know when a job is done.
60
HANDLE worker_job_event_done (LPWORKER);
62
/* Ask a job to stop processing.
64
void worker_job_stop (LPWORKER);
66
/* End a job submitted to worker.
68
void worker_job_finish (LPWORKER);
70
#endif /* _WINWORKER_H */