How can I poll web requests without blocking?

I have two web requests that I need to poll to find out when they will return. Ideally, I do not want to constantly test them in a closed loop. I would like to free the processor so that other processes can execute.

I am currently using the Perl Time :: HiRes :: sleep (0.100) function to free the CPU before testing to see if web requests have returned.

During testing under load, I see that the duration of sleep is "stretched." Ideally, I want to make sure that the duration of sleep is respected, but this processor is freed. Should I call another function to achieve this?

I am coding Perl on Linux 2.6.

+3
source share
3 answers

, , .

, -, .

- - - , , select.

; , , -, , .

, , , select . : http://search.cpan.org/dist/HTTP-Async/ , , .

+14

, . POE, EV .

, . .

+2

, Linux. " ", Linux - " ".

@Douglas Leeder: select, ​​ , - . select, Time:: HiRes - ( ).

+1

Source: https://habr.com/ru/post/1703757/


All Articles