Concurrency in D
FrankLike via Digitalmars-d
digitalmars-d at puremagic.com
Tue Feb 24 05:14:16 PST 2015
There is a int[] ,how to use the Fiber execute it ?
Such as :
import std.stdio;
import core.thread;
class DerivedFiber : Fiber
{
this()
{
super( &run );
}
private :
void run()
{
printf( "Derived fiber running.\n" );
faa();
}
}
int[] v;
void ftread()
{
DerivedFiber work = new DerivedFiber();
writeln( " will call " );
work.call();
writeln( " stop call " );
}
void faa()
{
writeln( " start " );
//Fiber.yield();
writeln( " start yield " );
foreach(c;v)
{
writeln( " current n is ",b(c) );
}
}
void b(int n)
{
...//do someting for n
}
void main()
{
int n=1;
while(n<=10_001)
{
v~=n;
n+=5000;
}
printf( "Execution returned to calling context.\n" );
ftread();
}
-------------end------------
I dont's think it's a good work.
How about you?
Thank you.
More information about the Digitalmars-d
mailing list