提交 c731686f 编写于 作者: R Rodrigo Kumpera

Don't include the poll backed directly into the threadpool source code.

上级 ebf7c45f
......@@ -194,6 +194,7 @@ common_sources = \
threadpool.c \
threadpool.h \
threadpool-internals.h \
tpool-poll.c \
verify.c \
verify-internals.h \
wrapper-types.h \
......
......@@ -3,10 +3,34 @@
#include <glib.h>
#include <mono/metadata/object.h>
#include <mono/metadata/mono-hash.h>
#include <mono/metadata/mono-mlist.h>
#include <mono/utils/mono-compiler.h>
typedef struct {
mono_mutex_t io_lock; /* access to sock_to_state */
int inited; // 0 -> not initialized , 1->initializing, 2->initialized, 3->cleaned up
MonoGHashTable *sock_to_state;
gint event_system;
gpointer event_data;
void (*modify) (gpointer p, int fd, int operation, int events, gboolean is_new);
void (*wait) (gpointer sock_data);
void (*shutdown) (gpointer event_data);
} SocketIOData;
void mono_thread_pool_remove_socket (int sock) MONO_INTERNAL;
gboolean mono_thread_pool_is_queue_array (MonoArray *o) MONO_INTERNAL;
void mono_internal_thread_unhandled_exception (MonoObject* exc) MONO_INTERNAL;
//TP implementations
gpointer tp_poll_init (SocketIOData *data) MONO_INTERNAL;
//TP internals the impls use
void check_for_interruption_critical (void) MONO_INTERNAL;
void socket_io_cleanup (SocketIOData *data) MONO_INTERNAL;
MonoObject *get_io_event (MonoMList **list, gint event) MONO_INTERNAL;
int get_events_from_list (MonoMList *list) MONO_INTERNAL;
void threadpool_append_async_io_jobs (MonoObject **jobs, gint njobs) MONO_INTERNAL;
#endif
......@@ -83,18 +83,6 @@ enum {
MONITOR_STATE_SLEEPING
};
typedef struct {
mono_mutex_t io_lock; /* access to sock_to_state */
int inited; // 0 -> not initialized , 1->initializing, 2->initialized, 3->cleaned up
MonoGHashTable *sock_to_state;
gint event_system;
gpointer event_data;
void (*modify) (gpointer p, int fd, int operation, int events, gboolean is_new);
void (*wait) (gpointer sock_data);
void (*shutdown) (gpointer event_data);
} SocketIOData;
static SocketIOData socket_io_data;
/* Keep in sync with the System.MonoAsyncCall class which provides GC tracking */
......@@ -148,11 +136,7 @@ static void threadpool_kill_idle_threads (ThreadPool *tp);
static gboolean threadpool_start_thread (ThreadPool *tp);
static void threadpool_kill_thread (ThreadPool *tp);
static void monitor_thread (gpointer data);
static void socket_io_cleanup (SocketIOData *data);
static MonoObject *get_io_event (MonoMList **list, gint event);
static int get_events_from_list (MonoMList *list);
static int get_event_from_state (MonoSocketAsyncResult *state);
static void check_for_interruption_critical (void);
static MonoClass *async_call_klass;
static MonoClass *socket_async_call_klass;
......@@ -196,7 +180,7 @@ enum {
AIO_OP_LAST
};
#include <mono/metadata/tpool-poll.c>
// #include <mono/metadata/tpool-poll.c>
#ifdef HAVE_EPOLL
#include <mono/metadata/tpool-epoll.c>
#elif defined(USE_KQUEUE_FOR_THREADPOOL)
......@@ -300,7 +284,10 @@ is_sdp_asyncreadhandler (MonoDomain *domain, MonoClass *klass)
#ifdef DISABLE_SOCKETS
#define socket_io_cleanup(x)
void
socket_io_cleanup (SocketIOData *data)
{
}
static int
get_event_from_state (MonoSocketAsyncResult *state)
......@@ -309,7 +296,7 @@ get_event_from_state (MonoSocketAsyncResult *state)
return -1;
}
static int
int
get_events_from_list (MonoMList *list)
{
return 0;
......@@ -317,7 +304,7 @@ get_events_from_list (MonoMList *list)
#else
static void
void
socket_io_cleanup (SocketIOData *data)
{
mono_mutex_lock (&data->io_lock);
......@@ -355,7 +342,7 @@ get_event_from_state (MonoSocketAsyncResult *state)
}
}
static int
int
get_events_from_list (MonoMList *list)
{
MonoSocketAsyncResult *state;
......@@ -404,7 +391,7 @@ threadpool_jobs_dec (MonoObject *obj)
return FALSE;
}
static MonoObject *
MonoObject *
get_io_event (MonoMList **list, gint event)
{
MonoObject *state;
......@@ -1237,6 +1224,12 @@ threadpool_append_job (ThreadPool *tp, MonoObject *ar)
threadpool_append_jobs (tp, &ar, 1);
}
void
threadpool_append_async_io_jobs (MonoObject **jobs, gint njobs)
{
threadpool_append_jobs (&async_io_tp, jobs, njobs);
}
static void
threadpool_append_jobs (ThreadPool *tp, MonoObject **jobs, gint njobs)
{
......@@ -1529,7 +1522,7 @@ clear_thread_state (void)
ves_icall_System_Threading_Thread_SetState (thread, ThreadState_Background);
}
static void
void
check_for_interruption_critical (void)
{
MonoInternalThread *thread;
......
......@@ -8,6 +8,15 @@
* Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
* Copyright 2004-2011 Novell, Inc (http://www.novell.com)
*/
#include <config.h>
#include <glib.h>
#include <errno.h>
#include <mono/metadata/mono-ptr-array.h>
#include <mono/metadata/threadpool.h>
#include <mono/metadata/threadpool-internals.h>
#include <mono/utils/mono-semaphore.h>
#include <mono/utils/mono-poll.h>
#define INIT_POLLFD(a, b, c) {(a)->fd = b; (a)->events = c; (a)->revents = 0;}
struct _tp_poll_data {
......@@ -22,7 +31,7 @@ static void tp_poll_shutdown (gpointer event_data);
static void tp_poll_modify (gpointer p, int fd, int operation, int events, gboolean is_new);
static void tp_poll_wait (gpointer p);
static gpointer
gpointer
tp_poll_init (SocketIOData *data)
{
tp_poll_data *result;
......@@ -315,7 +324,7 @@ tp_poll_wait (gpointer p)
}
}
mono_mutex_unlock (&socket_io_data->io_lock);
threadpool_append_jobs (&async_io_tp, (MonoObject **) async_results.data, nresults);
threadpool_append_async_io_jobs ((MonoObject **) async_results.data, nresults);
mono_ptr_array_clear (async_results);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册