Skip to content

Commit

Permalink
fix race condition in sample
Browse files Browse the repository at this point in the history
  • Loading branch information
tjanczuk committed Mar 29, 2013
1 parent c15c863 commit 6fbb4b8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions samples/111_clr_listener.js
Expand Up @@ -15,8 +15,7 @@ var createController = edge.func(function () {/*
{
return new {
yieldControl = (Func<object,Task<object>>)((i) => {
Startup.AcquireControl();
return Startup.tcs.Task;
return Startup.AcquireControl();
}),
regainControl = (Func<object,Task<object>>)(async (i) => {
Startup.ReleaseControl();
Expand All @@ -25,7 +24,7 @@ var createController = edge.func(function () {/*
};
}
static void AcquireControl()
static Task<object> AcquireControl()
{
// single threaded; always called on V8 thread
Expand All @@ -34,7 +33,9 @@ var createController = edge.func(function () {/*
throw new InvalidOperationException("CLR already controls the lifetime of the process.");
}
tcs = new TaskCompletionSource<object>();
TaskCompletionSource<object> tmp = new TaskCompletionSource<object>();
tcs = tmp;
return tmp.Task;
}
public static void ReleaseControl()
Expand Down

0 comments on commit 6fbb4b8

Please sign in to comment.