Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2017-07

Cross OS API Wrappers

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

R0b0t1

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?

R0b0t1.

Reply by email

Michael Van Canneyt
to R0b0t1
R0b0t1 wrote 18 lines
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.

Reply by email