Author: gonzalo
Date: 2005-04-17 22:38:39 -0400 (Sun, 17 Apr 2005)
New Revision: 43179
Modified:
trunk/mono/mono/metadata/ChangeLog
trunk/mono/mono/metadata/threadpool.c
Log:
2005-04-17 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* threadpool.c: recv/send are now performed before going back to managed
code to save one transition.
Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog 2005-04-17 23:07:26 UTC (rev 43178)
+++ trunk/mono/mono/metadata/ChangeLog 2005-04-18 02:38:39 UTC (rev 43179)
@@ -1,3 +1,8 @@
+2005-04-17 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+ * threadpool.c: recv/send are now performed before going back to managed
+ code to save one transition.
+
2005-04-16 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* metadata/socket-io.c: fixed semantics in Socket.Blocking icall.
@@ -8,8 +13,9 @@
2005-04-16 Zoltan Varga <[EMAIL PROTECTED]>
- * reflection.c reflection.h: Fix handling of parameter defaults in
dynamic
- methods. Also fixes handling of parameter attributes. Fixes #74609.
+ * reflection.c reflection.h: Fix handling of parameter defaults in
+ dynamic methods. Also fixes handling of parameter attributes.
+ Fixes #74609.
* mono-debug.c (mono_debug_close_image): Fix warning.
Modified: trunk/mono/mono/metadata/threadpool.c
===================================================================
--- trunk/mono/mono/metadata/threadpool.c 2005-04-17 23:07:26 UTC (rev
43178)
+++ trunk/mono/mono/metadata/threadpool.c 2005-04-18 02:38:39 UTC (rev
43179)
@@ -103,10 +103,10 @@
} ASyncCall;
static void async_invoke_thread (gpointer data);
-static void append_job (CRITICAL_SECTION *cs, GList **plist, MonoAsyncResult
*ar);
+static void append_job (CRITICAL_SECTION *cs, GList **plist, gpointer ar);
static void start_thread_or_queue (MonoAsyncResult *ares);
static void mono_async_invoke (MonoAsyncResult *ares);
-static MonoAsyncResult *dequeue_job (CRITICAL_SECTION *cs, GList **plist);
+static gpointer dequeue_job (CRITICAL_SECTION *cs, GList **plist);
static GList *async_call_queue = NULL;
static GList *async_io_queue = NULL;
@@ -196,6 +196,14 @@
return events;
}
+#define ICALL_RECV(x) ves_icall_System_Net_Sockets_Socket_Receive_internal (\
+ (SOCKET) x->handle, x->buffer, x->offset,
x->size,\
+ x->socket_flags, &x->error);
+
+#define ICALL_SEND(x) ves_icall_System_Net_Sockets_Socket_Send_internal (\
+ (SOCKET) x->handle, x->buffer, x->offset,
x->size,\
+ x->socket_flags, &x->error);
+
static void
async_invoke_io_thread (gpointer data)
{
@@ -206,13 +214,24 @@
thread->state |= ThreadState_Background;
for (;;) {
+ MonoSocketAsyncResult *state;
MonoAsyncResult *ar;
- ar = (MonoAsyncResult *) data;
- if (ar) {
+ state = (MonoSocketAsyncResult *) data;
+ if (state) {
InterlockedDecrement (&pending_io_items);
+ ar = state->ares;
/* worker threads invokes methods in different domains,
* so we need to set the right domain here */
+ switch (state->operation) {
+ case AIO_OP_RECEIVE:
+ state->total = ICALL_RECV (state);
+ break;
+ case AIO_OP_SEND:
+ state->total = ICALL_SEND (state);
+ break;
+ }
+
domain = ((MonoObject *)ar)->vtable->domain;
if (mono_domain_set (domain, FALSE)) {
mono_thread_push_appdomain_ref (domain);
@@ -260,7 +279,7 @@
}
static void
-start_io_thread_or_queue (MonoAsyncResult *ares)
+start_io_thread_or_queue (MonoSocketAsyncResult *ares)
{
int busy, worker;
MonoDomain *domain;
@@ -302,7 +321,7 @@
g_print ("Dispatching event %d on socket %d\n", event,
state->handle);
#endif
InterlockedIncrement (&pending_io_items);
- start_io_thread_or_queue (state->ares);
+ start_io_thread_or_queue (state);
}
return oldlist;
@@ -992,7 +1011,7 @@
}
static void
-append_job (CRITICAL_SECTION *cs, GList **plist, MonoAsyncResult *ar)
+append_job (CRITICAL_SECTION *cs, GList **plist, gpointer ar)
{
GList *tmp, *list;
@@ -1012,17 +1031,17 @@
LeaveCriticalSection (cs);
}
-static MonoAsyncResult *
+static gpointer
dequeue_job (CRITICAL_SECTION *cs, GList **plist)
{
- MonoAsyncResult *ar = NULL;
+ gpointer ar = NULL;
GList *tmp, *tmp2, *list;
EnterCriticalSection (cs);
list = *plist;
tmp = list;
if (tmp) {
- ar = (MonoAsyncResult *) tmp->data;
+ ar = tmp->data;
tmp->data = NULL;
tmp2 = tmp;
for (tmp2 = tmp; tmp2->next != NULL; tmp2 = tmp2->next);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches