digitalmars.D.learn - Passing arguments to a new thread
- Mars (7/7) Jan 20 2012 Hello everybody.
- Timon Gehr (3/9) Jan 20 2012 See std.concurrency.
- Mars (6/19) Jan 20 2012 Very interesting, thank you. I'm currently writing a little
Hello everybody. As the title states, I want to run a function in a new thread, and pass it some arguments. How would I do that? I guess I could make a class, deriving from Thread, and work with it, but out of curiosity, I'd like to know if it's possible with a simple function. Mars
Jan 20 2012
On 01/20/2012 03:12 PM, Mars wrote:Hello everybody. As the title states, I want to run a function in a new thread, and pass it some arguments. How would I do that? I guess I could make a class, deriving from Thread, and work with it, but out of curiosity, I'd like to know if it's possible with a simple function. MarsSee std.concurrency. auto tid = spawn(&function, arg1, arg2, arg3, ...);
Jan 20 2012
On Friday, 20 January 2012 at 15:33:34 UTC, Timon Gehr wrote:On 01/20/2012 03:12 PM, Mars wrote:Very interesting, thank you. I'm currently writing a little client<>server application, and wanted to use 1 thread per client, for simplicity, but with this it's probably not harder to just loop through non-blocking recvs, and pass something to a handler thread. Am I right?Hello everybody. As the title states, I want to run a function in a new thread, and pass it some arguments. How would I do that? I guess I could make a class, deriving from Thread, and work with it, but out of curiosity, I'd like to know if it's possible with a simple function. MarsSee std.concurrency. auto tid = spawn(&function, arg1, arg2, arg3, ...);
Jan 20 2012