in reply to 'background' CPU process when Idle in AnyEvent
CPU crunching is done when Event loop is idle, but only for 0.1s to allow HTTP requests about the processed data to not be delayed more than ~100mS.
Time slicing is a way for OSes to implement "parallel" processing on (single-core) CPUs, so it seems like you've reinvented that :-) So:
What is generally used in this situation. A second thread?
Yes, or second process, or some other way of running multiple processes in parallel; there are various ways to implement communication between them. Though I don't know much about AnyEvent, a quick search reveals e.g. AnyEvent::Fork, whose documentation also links to several other similar modules in the AnyEvent family.
Update: Turns out I showed you an example of this using Mojo::IOLoop::Subprocess almost exactly two years ago.
|
|---|