digitalmars.D.learn - Something weird with threads.
- BizarreCake (30/30) Aug 07 2011 While messing with threads from std.concurrency, I've been getting
- Trass3r (6/8) Aug 07 2011 As the message already tells a class method yields a delegate and not a ...
While messing with threads from std.concurrency, I've been getting this weird problem. The code below, runs perfectly fine. ------------------------------------------- import std.concurrency; void main( ) { spawn( &func ); } void func( ) { } -------------------------------------------- But when func( ) is moved to a class: ------------------------------------------- import std.concurrency; void main( ) { auto c = new C; spawn( &c.func ); } class C { void func( ) { } } -------------------------------------------- doesn't compile at all. It produces the following errors: - Error: template std.concurrency.spawn(T...) does not match any function template declaration - Error: template std.concurrency.spawn(T...) cannot deduce template function from argument types !()(void delegate()) Am I doing it wrong? Is there a workaround? Thanks.
Aug 07 2011
- Error: template std.concurrency.spawn(T...) cannot deduce template function from argument types !()(void delegate())As the message already tells a class method yields a delegate and not a function. Check if that method could be made static. But if you really need to do it this way, you may create a static wrapper function that calls the method on a particular class instance. You should be able to use a function literal as well.
Aug 07 2011