Merge pull request #1624 from esdrubal/getprocesstimes
[mono.git] / mono / metadata / threadpool-ms.h
1 #ifndef _MONO_THREADPOOL_MICROSOFT_H_
2 #define _MONO_THREADPOOL_MICROSOFT_H_
3
4 #include <config.h>
5 #include <glib.h>
6
7 #include <mono/metadata/exception.h>
8
9 #define SMALL_STACK (sizeof (gpointer) * 32 * 1024)
10
11 enum {
12         STATUS_NOT_INITIALIZED,
13         STATUS_INITIALIZING,
14         STATUS_INITIALIZED,
15         STATUS_CLEANING_UP,
16         STATUS_CLEANED_UP,
17 };
18
19 typedef struct _MonoRuntimeWorkItem MonoRuntimeWorkItem;
20 typedef struct _MonoNativeOverlapped MonoNativeOverlapped;
21
22 static void G_GNUC_UNUSED
23 mono_threadpool_ms_init (void)
24 {
25         /* Initialization is done lazily */
26 }
27
28 static void G_GNUC_UNUSED
29 mono_threadpool_ms_init_tls (void)
30 {
31         /* The WSQ is now implemented in managed */
32 }
33
34 void
35 mono_threadpool_ms_cleanup (void);
36
37 MonoAsyncResult *
38 mono_threadpool_ms_add (MonoObject *target, MonoMethodMessage *msg, MonoDelegate *async_callback, MonoObject *state);
39 MonoObject *
40 mono_threadpool_ms_finish (MonoAsyncResult *ares, MonoArray **out_args, MonoObject **exc);
41
42 gboolean
43 mono_threadpool_ms_remove_domain_jobs (MonoDomain *domain, int timeout);
44
45 void
46 mono_threadpool_ms_suspend (void);
47 void
48 mono_threadpool_ms_resume (void);
49
50 static gboolean G_GNUC_UNUSED
51 mono_threadpool_ms_is_queue_array (MonoArray *arr)
52 {
53         /* The queue is in managed code */
54         return FALSE;
55 }
56
57 void
58 ves_icall_System_Threading_MonoRuntimeWorkItem_ExecuteWorkItem (MonoRuntimeWorkItem *rwi);
59
60 void
61 ves_icall_System_Threading_Microsoft_ThreadPool_GetAvailableThreadsNative (gint *worker_threads, gint *completion_port_threads);
62 void
63 ves_icall_System_Threading_Microsoft_ThreadPool_GetMinThreadsNative (gint *worker_threads, gint *completion_port_threads);
64 void
65 ves_icall_System_Threading_Microsoft_ThreadPool_GetMaxThreadsNative (gint *worker_threads, gint *completion_port_threads);
66 gboolean
67 ves_icall_System_Threading_Microsoft_ThreadPool_SetMinThreadsNative (gint worker_threads, gint completion_port_threads);
68 gboolean
69 ves_icall_System_Threading_Microsoft_ThreadPool_SetMaxThreadsNative (gint worker_threads, gint completion_port_threads);
70 void
71 ves_icall_System_Threading_Microsoft_ThreadPool_InitializeVMTp (gboolean *enable_worker_tracking);
72 gboolean
73 ves_icall_System_Threading_Microsoft_ThreadPool_NotifyWorkItemComplete (void);
74 void
75 ves_icall_System_Threading_Microsoft_ThreadPool_NotifyWorkItemProgressNative (void);
76 void
77 ves_icall_System_Threading_Microsoft_ThreadPool_ReportThreadStatus (gboolean is_working);
78 gboolean
79 ves_icall_System_Threading_Microsoft_ThreadPool_RequestWorkerThread (void);
80
81 static gboolean G_GNUC_UNUSED
82 ves_icall_System_Threading_Microsoft_ThreadPool_PostQueuedCompletionStatus (MonoNativeOverlapped *native_overlapped)
83 {
84         /* This copy the behavior of the current Mono implementation */
85         mono_raise_exception (mono_get_exception_not_implemented (NULL));
86         return FALSE;
87 }
88
89 static gboolean G_GNUC_UNUSED
90 ves_icall_System_Threading_Microsoft_ThreadPool_BindIOCompletionCallbackNative (gpointer file_handle)
91 {
92         /* This copy the behavior of the current Mono implementation */
93         return TRUE;
94 }
95
96 static gboolean G_GNUC_UNUSED
97 ves_icall_System_Threading_Microsoft_ThreadPool_IsThreadPoolHosted (void)
98 {
99         return FALSE;
100 }
101
102 /* Internals */
103
104 void
105 mono_threadpool_ms_enqueue_async_result (MonoDomain *domain, MonoAsyncResult *async_result);
106 void
107 mono_threadpool_ms_enqueue_work_item (MonoDomain *domain, MonoObject *work_item);
108
109 #endif // _MONO_THREADPOOL_MICROSOFT_H_