Whitch can replace std::bind/boost::bind ?
Atila Neves via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Mar 18 04:09:37 PDT 2016
On Friday, 18 March 2016 at 10:50:34 UTC, Dsby wrote:
>
> foreach (i ; 0..4) {
> auto th = new Thread(delegate(){listRun(i);});//this is erro
> _thread[i]= th;
> th.start();
> }
>
> void listRun(int i)
> {
> writeln("i = ", i); // the value is not(0,1,2,3), it all
> is 2.
> }
>
>
> I want to know how to use it like std::bind.
I would suggest not using Thread directly:
foreach(i; 0..4) {
auto tid = spawn(&listRun, i); //from std.concurrency
_tid[i] = tid;
}
Atila
More information about the Digitalmars-d-learn
mailing list