<div dir="ltr"><div><div><div>Thanks for the response, I think my original email basically outlined my issue, but I will break it down.<br><br></div>If 10 people visit my page at the moment, and the page has to retrieve database/memcached info for the 10 people, and it takes 1 second to do all the pre-work to load the page, then each of those requests for each person, is done separately, taking a total of 10 seconds for the last person to retrieve their data, since it has to wait for each other process to finish before attending to the next person.<br><br></div>At a basic level in nodejs, you do this (as an example):<br><br>router.get('/', function (req, res, next) {<br> Post.find(function(err, Patients) {<br> if (err) { return next(err) }<br> res.json(People)<br> },'Firstname Surname')<br>})<br><br></div>And although this is per session blocker in node, it still allows other sessions to continue. <br>I want to know how to achieve this or a similar effect in Dancer2. Or, do I just look at it as an issue with Perl and solve it through something like <tt>AnyEvent::Util::fork_call<br><br></tt><div><br></div><div>David<br></div><div><div><br><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 18, 2015 at 12:32 AM, Rick Leir <span dir="ltr"><<a href="mailto:richard.leir@canadiana.ca" target="_blank">richard.leir@canadiana.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 17, 2015 at 7:00 AM, <span dir="ltr"><<a href="mailto:dancer-users-request@dancer.pm" target="_blank">dancer-users-request@dancer.pm</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
delayed {<br>
my $TextToWrite = ReturnText();<br>
sleep(10); # Do something that takes a few seconds<br>
content "$TextToWrite";<br>
done;<br>
};</blockquote></div>The sleep call will always cause blocking, even a sleep(0). Likewise a flush. In the sense that there is a context switch to some other thread or process. <br><br>How are you testing whether it is blocking? Sorry, I do not know what you are trying to do.<br><br>Linux will not schedule a cpu intensive task to the exclusion of I/O. You can affect its scheduling using nice: <br><a href="http://stackoverflow.com/questions/2012852/control-a-perl-scripts-cpu-utilization" target="_blank">http://stackoverflow.com/questions/2012852/control-a-perl-scripts-cpu-utilization</a><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">If you really want nonblocking then you can look at nice for io<br><a href="http://linux.die.net/man/1/ionice" target="_blank">http://linux.die.net/man/1/ionice</a><br></div><div class="gmail_extra">or spawn a C program with pthreads and freeze your screen!<br></div><div class="gmail_extra">cheers -- Rick <br></div><div class="gmail_extra"><br></div></div>
<br>_______________________________________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" rel="noreferrer" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
<br></blockquote></div><br></div>