[sgen] Implement a simple thread pool and do concurrent sweep with it.
[mono.git] / mono / metadata / sgen-thread-pool.h
1 /*
2  * sgen-thread-pool.h: Threadpool for all concurrent GC work.
3  *
4  * Copyright (C) 2015 Xamarin Inc
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License 2.0 as published by the Free Software Foundation;
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License 2.0 along with this library; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20 #ifndef __MONO_SGEN_THREAD_POOL_H__
21 #define __MONO_SGEN_THREAD_POOL_H__
22
23 typedef struct _SgenThreadPoolJob SgenThreadPoolJob;
24
25 typedef void (*SgenThreadPoolJobFunc) (SgenThreadPoolJob *job);
26
27 struct _SgenThreadPoolJob {
28         SgenThreadPoolJobFunc func;
29         volatile gint32 state;
30 };
31
32 void sgen_thread_pool_init (int num_threads);
33
34 void sgen_thread_pool_job_init (SgenThreadPoolJob *job, SgenThreadPoolJobFunc func);
35 void sgen_thread_pool_job_enqueue (SgenThreadPoolJob *job);
36
37 void sgen_thread_pool_wait_for_all_jobs (void);
38
39 #endif