[Lazarus] Cross OS API Wrappers

Michael Van Canneyt michael at freepascal.org
Mon Jul 10 09:07:18 CEST 2017



On Mon, 10 Jul 2017, R0b0t1 via Lazarus wrote:

> Hello,
>
> I was wondering if cross-platform (Linux, BSD, Windows) wrappers exist
> for certain goals like "create a system timer" or "use asynchronous
> IO."
>
> A good example would be a class which uses timerfds and epoll on
> Linux, kqueues and kevent on BSD, or Waitable Timers on Windows to do
> very accurate asynchronous timing. The typical solution to a lot of
> problems like this (as seen on the Lazarus IDE forums, but also on
> answers on other sites tagged as using Delphi) is to use more threads.
> This works but isn't necessarily an ideal solution.
>
> I have personal interest in adding code to accomplish things like the
> above, but some of the names would conflict with things which already
> behave in a certain way (i.e. I can't call the class outlined above
> "TTimer"). Is there a recommended way to name things and a recommended
> place to add what I want to do to either the FP units or the LCL?

There are no conventions to speak of. But TAsyncTimer seems an obvious
choice.

You may want to check libasync.pp and fpasync in the fcl-async package
before reinventing the wheel. It is old code, but is a nice start.

Michael.


More information about the Lazarus mailing list