[Lazarus] HTTP client/server components committed.

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Tue May 17 11:32:40 CEST 2011



On Tue, 17 May 2011, Michael Schnell wrote:

> On 05/17/2011 10:34 AM, michael.vancanneyt at wisa.be wrote:
>> 
>> Any implementation will always use polling. You may hide it under some kind
>> of abstraction, but it's always polling. On unix with select() or epoll(), 
>> on Windows with PeekMessage/GetMessage and friends. Your Delphi windows 
>> timer uses PeekMessage/GetMessage by the message pump as well. 
>
> Sorry, but you are wrong here.
>
> Linux: select() and epoll() don't do polling (even if the name "epoll" is 
> misleading). Theses API calls make the thread sleep with zero CPU time until 
> one of the appropriate events is fired (by a Kernel driver or another thread) 
> and then the Kernel wakes up the thread and same is scheduled according its 
> priority setting (i.e. ASAP).
>
> So the problems of polling are avoided. (Such as latency when doing a slow 
> polling e.g. by means of "sleep()", and high performance overhead when doing 
> fast polling).

That's just name picking.  Polling = asking a question.

>From the point of view of the application, it is polling the kernel for availability 
of data: the call returns as soon as there is data or the kernel decides
there will be no data in a reasonable time frame.

So there is no 'event' involved at the application level, just a call to the
kernel.

What you describe as 'polling' is the crudest form of user-land polling,
which is of course very CPU intensive and to be avoided at all costs.

Michael.




More information about the Lazarus mailing list