Skip to content

Commit

Permalink
[AsyncResult] Use async_call type explicitely
Browse files Browse the repository at this point in the history
  • Loading branch information
luhenry committed Feb 12, 2016
1 parent 7e755d4 commit c4c0b7e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Expand Up @@ -45,7 +45,7 @@ public class AsyncResult : IAsyncResult, IMessageSink, IThreadPoolWorkItem {
object async_state;
WaitHandle handle;
Delegate async_delegate;
object object_data;
MonoAsyncCall async_call;
bool sync_completed;
bool completed;
bool endinvoke_called;
Expand Down Expand Up @@ -175,7 +175,6 @@ internal MonoMethodMessage CallMessage

void Invoke ()
{
MonoAsyncCall async_call = object_data as MonoAsyncCall;
if (async_call == null) {
/* Remoting case */
InvokeRemoting ();
Expand Down
8 changes: 5 additions & 3 deletions mono/metadata/object-internals.h
Expand Up @@ -278,12 +278,14 @@ typedef struct {
MonoString *param_name;
} MonoArgumentException;

typedef struct _MonoAsyncCall MonoAsyncCall;

typedef struct {
MonoObject object;
MonoObject *async_state;
MonoObject *handle;
MonoDelegate *async_delegate;
MonoObject *object_data;
MonoAsyncCall *async_call;
MonoBoolean sync_completed;
MonoBoolean completed;
MonoBoolean endinvoke_called;
Expand Down Expand Up @@ -362,13 +364,13 @@ typedef struct {
} MonoMethodMessage;

/* Keep in sync with the System.MonoAsyncCall */
typedef struct {
struct _MonoAsyncCall {
MonoObject object;
MonoMethodMessage *msg;
MonoObject *state;
MonoObject *res;
MonoArray *out_args;
} MonoAsyncCall;
};

typedef struct {
MonoObject obj;
Expand Down
4 changes: 2 additions & 2 deletions mono/metadata/threadpool-ms.c
Expand Up @@ -1340,7 +1340,7 @@ mono_threadpool_ms_begin_invoke (MonoDomain *domain, MonoDelegate *target, MonoM
MONO_OBJECT_SETREF (async_call, state, state);

async_result = mono_async_result_new (domain, target, async_call->state, async_callback);
MONO_OBJECT_SETREF (async_result, object_data, (MonoObject*) async_call);
MONO_OBJECT_SETREF (async_result, async_call, async_call);

mono_threadpool_ms_enqueue_work_item (domain, (MonoObject*) async_result);

Expand Down Expand Up @@ -1387,7 +1387,7 @@ mono_threadpool_ms_end_invoke (MonoAsyncResult *ares, MonoArray **out_args, Mono
MONO_FINISH_BLOCKING;
}

ac = (MonoAsyncCall*) ares->object_data;
ac = ares->async_call;
g_assert (ac);

*exc = ac->msg->exc; /* FIXME: GC add write barrier */
Expand Down

0 comments on commit c4c0b7e

Please sign in to comment.