Skip Menu |

This queue is for tickets about the IO-Lambda CPAN distribution.

Report information
The Basics
Id: 57075
Status: rejected
Priority: 0/
Queue: IO-Lambda

People
Owner: Nobody in particular
Requestors: KES [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.15
Fixed in: (no value)



Subject: unexpected behaviour
Why obj lambda is runned, it is not expected. Also notice - it is runned but is not finished completely. Two bugs =(
Subject: test.pl
#!/usr/bin/perl use IO::Lambda qw(:constants); my $obj = IO::Lambda-> new; # Either 3 or time + 3 will do. See "Time" section for more info $obj-> watch_timer( 3, sub { print "I've slept 3 seconds!\n" }); $obj-> watch_io( IO_READ, \*STDIN, 15, sub { my ( $self, $ok) = @_; print $ok ? "stdin is readable!\n" : "stdin is not readable within 5 seconds\n"; }); my $a = IO::Lambda-> new; $a-> watch_timer( 3, sub { print "3 seconds!\n" }); my $b = IO::Lambda-> new; # A lambda can wait for more than one event or lambda. # A lambda can be awaited by more than one lambda. $b-> watch_lambda( $a, sub { print "lambda #1 is finished!\n"}); #IO::Lambda::run; #IO::Lambda::run; $b->wait;
Show quoted text
> Why obj lambda runs, it is not expected.
wait() doesn't prevent other lambdas from running, it's only synchronous with regard to the caller lambda Show quoted text
> Also notice - it runs but is not finished completely.
Also correct, it's not forbidden to abort a program while some lambdas are still running. Either use $obj->wait to wait for that particular lambda, or IO::Lambda::run() that stops only when there are no more lambdas. Show quoted text
> Two bugs =(
The test script works as it should, so no bugs confirmed. You're welcome to close the ticket if there's no more about it.
ok. How to create lambda and do not run it at this moment while other lambdas are normally running? if this is not possible at current design then that is design bug Also I have many notices at doc. Write to ICQ#235367958 after 04.05.2010
Суб Май 01 12:03:24 2010, KES писал: Show quoted text
> ok. How to create lambda and do not run it at this moment while other > lambdas are normally running?
It is not possible to pause a lambda once it has started. Show quoted text
> Also I have many notices at doc.
patches are welcome
Суб Май 01 17:07:18 2010, KARASIK писал: Show quoted text
> Суб Май 01 12:03:24 2010, KES писал:
> > ok. How to create lambda and do not run it at this moment while other > > lambdas are normally running?
> > It is not possible to pause a lambda once it has started.
I do not start obj lambda at all. Ok. See this test case: Some module uses your IO::Lambda: it craete lambda, run, wait and etc. I 'use that::module;' and wanna create my own lambda but got unexpectedly it is runned becase of 'that::module' ran its own lambda.
Show quoted text
> > It is not possible to pause a lambda once it has started.
> I do not start obj lambda at all.
Well, you do actually. Registering a callback and registering a timeout is an atomic operation. Show quoted text
> Ok. See this test case: > Some module uses your IO::Lambda: it craete lambda, run, wait and etc. > I 'use that::module;' and wanna create my own lambda but got > unexpectedly it is runned becase of 'that::module' ran its own lambda.
I don't think there would be any problem, because the optimal way to use lambda is asynchronous, and neither module A nor B would call blocking wait(), that's for the main program to do. Much like creating two windows in a GUI program: no matter what module creates a window, they run together in parallel. I agree though that IO::Lambda lacks finer control of event dispatch, also including event filtering. OTOH, consider the following code: $a-> wait_timer(3, ..); $b-> wait_timer(6, ..); $b-> wait; Here, programmer expects that $a's callback will be fired off in 3 seconds, however, if lambdas would run as you suggest, it would take 9 seconds, which I think is not good for the default behavior. If you really need to postpone a lambda until some external condition is triggered, I'd recommend to change the concept, like the following: $b-> watch_timer(...) $b-> wait; $obj-> watch_io(...) $obj-> wait Note though that blocking waiters are not that interesting to use, much like it is not so interesting to write GUI programs in blocking style. Ideally, your program would look like this: $a-> watch...; $b-> watch...; $obj-> watch...; IO::Lambda::run; So the cooperation runs to the fullest. Also you might find it useful to look at IO::Lambda::Mutex that can stop/start the flow until some external event is triggered.
you're also welcome to contact me off-list as McFist on #efnet and #rusnet
Вск Май 02 11:07:52 2010, KARASIK писал: Show quoted text
> you're also welcome to contact me off-list as McFist on #efnet and
#rusnet what is this? =) Show quoted text
> $a-> wait_timer(3, ..); > $b-> wait_timer(6, ..); > $b-> wait; > > Here, programmer expects that $a's callback will be fired off in 3 > seconds, however, if lambdas would run as you suggest, it would take 9 > seconds, which I think is not good for the default behavior.
Here, programmer expects that $a's callback will NOT be fired at all! You must not use this: IO::Lambda::run; this is EVIL as like Application->form->show() show only one form and does not show all Applications forms ;-) as though, you can do this: IO::Lambda::runall So also. Application->TFormA->Create; Application->TFormB->Create; Application->TFormB->Show; will not show TFormA, TFormC, .... TFormY
The behavior is correct and expected, the bug is not confirmed. Further discussion is welcome but off rt.cpan.org, please don't reopen.
Пнд Май 03 05:30:00 2010, KARASIK писал: Show quoted text
> The behavior is correct and expected, the bug is not confirmed. Further > discussion is welcome but off rt.cpan.org, please don't reopen.
can you give me address where that that irc channel is located?
Пнд Май 03 05:54:05 2010, KES писал: Show quoted text
> Пнд Май 03 05:30:00 2010, KARASIK писал:
> > The behavior is correct and expected, the bug is not confirmed. Further > > discussion is welcome but off rt.cpan.org, please don't reopen.
> > can you give me address where that that irc channel is located?