Last active
December 13, 2015 22:49
Revisions
-
zigorou revised this gist
Feb 19, 2013 . 2 changed files with 105 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ #!/usr/bin/env perl use strict; use warnings; use Coro; use AnyEvent; use AnyEvent::Log; $AnyEvent::Log::FILTER->level("debug"); my $channel = Coro::Channel->new(100); async { while (1) { my $q = $channel->get; # works AE::log( debug => sprintf("channel->get (pid: %s)", $$) ); $q->[0]->end; AE::log( debug => sprintf("guard->end (pid: %s)", $$) ); } }; sub { my $env = shift; AE::log( debug => sprintf("env (pid: %s)", $$) ); my $cv = AE::cv; async { AE::log( debug => sprintf("guard->begin (pid: %s)", $$) ); $env->{"psgix.exit_guard"}->begin; AE::log( debug => sprintf("channel->put (pid: %s)", $$) ); $channel->put([ $env->{"psgix.exit_guard"} ]); AE::log( debug => sprintf("cv->send (pid: %s)", $$) ); $cv->send; }; return sub { my $start_response = shift; AE::log( debug => sprintf("start_response (pid: %s)", $$) ); $cv->cb(sub { AE::log( debug => sprintf("start_response write (pid: %s)", $$) ); $start_response->([200, ["Content-Type" => "text/plain"], ["OK"]]); }); }; }; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ #!/usr/bin/env perl use strict; use warnings; use Coro; use AnyEvent; use AnyEvent::Log; $AnyEvent::Log::FILTER->level("debug"); my $channel = Coro::Channel->new(100); async { while (1) { my $q = $channel->get; # works AE::log( debug => sprintf("channel->get (pid: %s)", $$) ); $q->[0]->end; AE::log( debug => sprintf("guard->end (pid: %s)", $$) ); } }; async { AE::log( debug => sprintf("xxx (pid: %s)", $$) ); }; sub { my $env = shift; AE::log( debug => sprintf("env (pid: %s)", $$) ); my $cv = AE::cv; async { AE::log( debug => sprintf("before (pid: %s)", $$) ); }; async { AE::log( debug => sprintf("guard->begin (pid: %s)", $$) ); $env->{"psgix.exit_guard"}->begin; AE::log( debug => sprintf("channel->put (pid: %s)", $$) ); $channel->put([ $env->{"psgix.exit_guard"} ]); AE::log( debug => sprintf("cv->send (pid: %s)", $$) ); $cv->send; }; async { AE::log( debug => sprintf("after (pid: %s)", $$) ); }; return sub { my $start_response = shift; AE::log( debug => sprintf("start_response (pid: %s)", $$) ); $cv->cb(sub { AE::log( debug => sprintf("start_response write (pid: %s)", $$) ); $start_response->([200, ["Content-Type" => "text/plain"], ["OK"]]); # AE::log( debug => sprintf("start_response write end (pid: %s)", $$) ); }); }; }; -
zigorou created this gist
Feb 19, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ # Twiggy::Prefork