-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: renamed YieldReturn to YieldAssign and moved Yielders.Yield to…
… Coroutine.Yield BREAKING CHANGE: To better reflect that you "replace" the coroutine result of a yielder the name YieldReturn has been renamed to YieldAssign. Also moved Yielders.Yield to Coroutine.Yield to align with Task.Yield.
- Loading branch information
Showing
15 changed files
with
164 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
using Tenekon.Coroutines; | ||
using System.Diagnostics; | ||
using Tenekon.Coroutines; | ||
|
||
await Coroutine.Start(async () => | ||
{ | ||
Console.WriteLine(Environment.CurrentManagedThreadId); | ||
|
||
var t1 = await Coroutine.Factory.StartNew(async () => | ||
var t1 = await Coroutine.Factory.StartNew(new Func<Coroutine>(async () => | ||
{ | ||
Console.WriteLine("Hello World " + Environment.CurrentManagedThreadId); | ||
Thread.Sleep(3000); | ||
Console.WriteLine("Finished"); | ||
}); | ||
Console.WriteLine(DateTime.UtcNow - Process.GetCurrentProcess().StartTime.ToUniversalTime() + ": Finished"); | ||
})); | ||
|
||
var t2 = await Coroutine.Factory.StartNew(async () => | ||
var t2 = await Coroutine.Factory.StartNew(new Func<Coroutine>(async () => | ||
{ | ||
Console.WriteLine("Hello World " + Environment.CurrentManagedThreadId); | ||
Thread.Sleep(3000); | ||
Console.WriteLine("Finished"); | ||
}); | ||
Console.WriteLine(DateTime.UtcNow - Process.GetCurrentProcess().StartTime.ToUniversalTime() + ": Finished"); | ||
})); | ||
|
||
await Task.WhenAll(t1.AsTask(), t2.AsTask()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Tenekon.Coroutines.Sources; | ||
using static Tenekon.Coroutines.Yielders.Arguments; | ||
|
||
namespace Tenekon.Coroutines; | ||
|
||
partial struct Coroutine | ||
{ | ||
public static Coroutine Yield() | ||
{ | ||
var completionSource = ManualResetCoroutineCompletionSource<VoidCoroutineResult>.RentFromCache(); | ||
var argument = new YieldArgument(completionSource); | ||
return new(completionSource, argument); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.