in reply to Re^2: Doing two things at once, fork question.
in thread Doing two things at once, fork question.
Is there anyway I can call async with a method? I'm not sure what the syntax would be...
Yes. (Update: Corrected method syntax)
# normal sub - no parameters. my $thread = async \&subname; # sub with args my $thread = async \&subname, $arg1, $arg2; # method - no parameters. my $thread = async \&pClass::method, $obj; # method with args my $thread = async \&Classname::method, $obj, $arg1, $arg2;
And note that async is just a functional alias for
my $thread = threads->create( \&sub, $arg1, $arg2 ); my $thread = threads->new( \&Classname::method, $obj, $arg1, $arg2 );
But note. Calling objects (object methods) across threads probably won't work in most cases.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Doing two things at once, fork question. (thread + method)
by tye (Sage) on Mar 07, 2008 at 23:25 UTC | |
by BrowserUk (Patriarch) on Mar 07, 2008 at 23:52 UTC | |
by tye (Sage) on Mar 08, 2008 at 03:00 UTC | |
by BrowserUk (Patriarch) on Mar 08, 2008 at 10:08 UTC |