Yield from function?
Profile Anaysis via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jan 31 02:41:11 PST 2017
On Tuesday, 31 January 2017 at 06:32:02 UTC, Ali Çehreli wrote:
> On 01/30/2017 08:12 PM, Profile Anaysis wrote:
>> [...]
>
> That's because the fiber is not in a callable state. (You can
> check with search.state.) Here is one where the fiber function
> lives (too) long:
>
> import std.stdio, std.concurrency, core.thread;
>
> class Search : Fiber
> {
> this() { super(&start); }
> int res = 0;
> void start() {
> while (true) {
> Fiber.yield();
> ++res;
> }
> }
> }
>
> void main()
> {
> auto search = new Search();
>
> foreach (i; 0 .. 5) {
> search.call();
> writeln(search.res);
> }
> }
>
> Ali
Thanks.
More information about the Digitalmars-d-learn
mailing list