[bcl] Enable tests for the monodroid profile.
[mono.git] / mono / sgen / 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  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
7  */
8
9 #ifndef __MONO_SGEN_THREAD_POOL_H__
10 #define __MONO_SGEN_THREAD_POOL_H__
11
12 typedef struct _SgenThreadPoolJob SgenThreadPoolJob;
13
14 typedef void (*SgenThreadPoolJobFunc) (void *thread_data, SgenThreadPoolJob *job);
15
16 struct _SgenThreadPoolJob {
17         const char *name;
18         SgenThreadPoolJobFunc func;
19         size_t size;
20         volatile gint32 state;
21 };
22
23 typedef void (*SgenThreadPoolThreadInitFunc) (void*);
24 typedef void (*SgenThreadPoolIdleJobFunc) (void*);
25 typedef gboolean (*SgenThreadPoolContinueIdleJobFunc) (void*);
26 typedef gboolean (*SgenThreadPoolShouldWorkFunc) (void*);
27
28 void sgen_thread_pool_init (int num_threads, SgenThreadPoolThreadInitFunc init_func, SgenThreadPoolIdleJobFunc idle_func, SgenThreadPoolContinueIdleJobFunc continue_idle_func, SgenThreadPoolShouldWorkFunc should_work_func, void **thread_datas);
29
30 void sgen_thread_pool_shutdown (void);
31
32 SgenThreadPoolJob* sgen_thread_pool_job_alloc (const char *name, SgenThreadPoolJobFunc func, size_t size);
33 /* This only needs to be called on jobs that are not enqueued. */
34 void sgen_thread_pool_job_free (SgenThreadPoolJob *job);
35
36 void sgen_thread_pool_job_enqueue (SgenThreadPoolJob *job);
37 /* This must only be called after the job has been enqueued. */
38 void sgen_thread_pool_job_wait (SgenThreadPoolJob *job);
39
40 void sgen_thread_pool_idle_signal (void);
41 void sgen_thread_pool_idle_wait (void);
42
43 void sgen_thread_pool_wait_for_all_jobs (void);
44
45 int sgen_thread_pool_is_thread_pool_thread (MonoNativeThreadId thread);
46
47 #endif