Mojo::IOLoop::Delay(3pm) User Contributed Perl Documentation Mojo::IOLoop::Delay(3pm)NAME
Mojo::IOLoop::Delay - Synchronize events
SYNOPSIS
use Mojo::IOLoop::Delay;
# Synchronize multiple events
my $delay = Mojo::IOLoop::Delay->new;
$delay->on(finish => sub { say 'BOOM!' });
for my $i (1 .. 10) {
$delay->begin;
Mojo::IOLoop->timer($i => sub {
say 10 - $i;
$delay->end;
});
}
# Wait for events if necessary
$delay->wait unless Mojo::IOLoop->is_running;
DESCRIPTION
Mojo::IOLoop::Delay synchronizes events for Mojo::IOLoop.
EVENTS
Mojo::IOLoop::Delay can emit the following events.
"finish"
$delay->on(finish => sub {
my $delay = shift;
...
});
Emitted safely once the active event counter reaches zero.
ATTRIBUTES
Mojo::IOLoop::Delay implements the following attributes.
"ioloop"
my $ioloop = $delay->ioloop;
$delay = $delay->ioloop(Mojo::IOLoop->new);
Loop object to control, defaults to the global Mojo::IOLoop singleton.
METHODS
Mojo::IOLoop::Delay inherits all methods from Mojo::EventEmitter and implements the following new ones.
"begin"
my $cb = $delay->begin;
Increment active event counter, the returned callback can be used instead of "end".
my $delay = Mojo::IOLoop->delay;
Mojo::UserAgent->new->get('mojolicio.us' => $delay->begin);
my $tx = $delay->wait;
"end"
$delay->end;
$delay->end(@args);
Decrement active event counter.
"wait"
my @args = $delay->wait;
Start "ioloop" and stop it again once the "finish" event gets emitted, only works when "ioloop" is not running already.
# Use the "finish" event to synchronize portably
$delay->on(finish => sub {
my ($delay, @args) = @_;
...
});
$delay->wait unless $delay->ioloop->is_running;
SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>.
perl v5.14.2 2012-09-05 Mojo::IOLoop::Delay(3pm)
Check Out this Related Man Page
Mojo::Server::PSGI(3pm) User Contributed Perl Documentation Mojo::Server::PSGI(3pm)NAME
Mojo::Server::PSGI - PSGI server
SYNOPSIS
use Mojo::Server::PSGI;
my $psgi = Mojo::Server::PSGI->new;
$psgi->unsubscribe('request');
$psgi->on(request => sub {
my ($psgi, $tx) = @_;
# Request
my $method = $tx->req->method;
my $path = $tx->req->url->path;
# Response
$tx->res->code(200);
$tx->res->headers->content_type('text/plain');
$tx->res->body("$method request for $path!");
# Resume transaction
$tx->resume;
});
my $app = $psgi->to_psgi_app;
DESCRIPTION
Mojo::Server::PSGI allows Mojo applications to run on all PSGI compatible servers.
See Mojolicious::Guides::Cookbook for more.
EVENTS
Mojo::Server::PSGI inherits all events from Mojo::Server.
METHODS
Mojo::Server::PSGI inherits all methods from Mojo::Server and implements the following new ones.
"run"
my $res = $psgi->run($env);
Run PSGI.
"to_psgi_app"
my $app = $psgi->to_psgi_app;
Turn Mojo application into PSGI application.
SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>.
perl v5.14.2 2012-09-05 Mojo::Server::PSGI(3pm)
When telneting to a SUN box and incorrectly spelling your password, there is a delay of approx. 5 seconds. Is there any way to shorten this time?
OS solaris 7 (1 Reply)
I am new to programming using the korn shell and I have a question:
Is there a way to take all the data in a file and insert it in another file, but between begin and end. Example below
begin
<-- Insert text here -->
end
Any suggustions would be much appreciated.<-- Insert text here... (2 Replies)
Hi,
I have a doubt in introducing a delay in the programs.
We know that we do have a sleep() function/api using which
we can bring a delay in terms of seconds.
A minimum delay can be atleast 1 second.
Now I'm bothered about how to introduce a delay that is just
less than a second. Like... (3 Replies)
hello
How can I go out to a "case" boucle, but not finish the program :
echo " your choice :"
read grp1
do
case ${grp1} in
1)grp1="toto1";;
2)grp1="toto2";;
3)grp1="toto3";;
4)grp1="toto4";;
5)grp1=t;;
6)grp1=t;;
... (3 Replies)
How to delay a process.
I need to to delay a process from 3sec.
At that 3sec other back ground processes also should stop.
(just sit 3sec for idle & then starts execution as normally)
I use sleep(3)-But it not stop the bg processes
I try to use loop but it not gurantee to wait 3sec.
... (2 Replies)
i tried to build a command to replaces the word "include" with
"exclude"
in each *.h type of file in a certain directory
and to display the lines in which the switch happened.
i did a command and i dont know why its not working
find /usr -name "*.h" -exec sed 's/include/exclude/g' {} \;... (2 Replies)
Hi all,
i would like to know how to introduce a delay in the execution of a cmd?
am trying to copy a file which is about 650 mb and then perform some actions on it..
however since its huge i would like to introduce a delay in exection until the process is over
i dont want it to proceed to... (10 Replies)
Hi,
I have strange problem executing some command on solaris 5.9
ps command does not finish(hangs) and runs forever without any result.
same with cc command too.Please suggest (1 Reply)
I have put together a website for Unix and Linux Lovers. It's only about 30% completed but I'm going to keep working on it. Please visit it and leave me any tips or suggestions.
Mojo's Linux Blog - Mojo's Blog (1 Reply)
Hello Guruz,
Could some please tell me how can I print via shell script “..............” with specific delay of 1 sec per “.”
I tried this, but it's started printing one by one. (2 Replies)
Hi,
I am trying to understand what would happen if ther is a loop without any delay like sleep statement, I feel that would add a lot of load onto the CPU. Trying to understand how the load is reduced by the introduction of sleep().
Thanks and regards
Zulfi (3 Replies)
I have a number, say 174. I need to write bash code that will find the first larger number that ends in 99. That would be 199 in this case. If the number were 1263, I would be looking for 1299, for 175438, I would want 175499, etc.
If the numbers were always three digit, I could just grab the... (11 Replies)
I have a BASH script that runs a continuous loop, reading a line from a file, and then spawning a background process to use it. I've placed "date" commands inside it to see where it's slowing down, and everything inside -- including reading the line from the file -- is fast, but the loop bogs... (34 Replies)