Platform independent alternatives

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Platform independent alternatives

Darius Blaszyk
ZeelandNet Webmail Hi,

I'm porting an app from Delphi to Lazarus when I came across a couple of functions from the windows unit. Can anyone help me finding the platform independent alternatives?

TerminateThread
WaitForSingleObject
CloseHandle

TIA, Darius

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Platform independent alternatives

etrusco
On Thu, Jun 23, 2011 at 3:18 PM,  <[hidden email]> wrote:
> Hi,
>
> I'm porting an app from Delphi to Lazarus when I came across a couple of
> functions from the windows unit. Can anyone help me finding the platform
> independent alternatives?
>
> TerminateThread

You shouldn't use it, generally speaking.


> WaitForSingleObject

AFAICT there's no - there can't be ;-) - equivalent. What is the
object you're waiting on?


> CloseHandle
>
> TIA, Darius
>

What object are you closing?

-Flávio
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Platform independent alternatives

Darius Blaszyk
 On Thu, 23 Jun 2011 15:38:18 -0300, Flávio Etrusco
 <[hidden email]> wrote:

> On Thu, Jun 23, 2011 at 3:18 PM,  <[hidden email]> wrote:
>> Hi,
>>
>> I'm porting an app from Delphi to Lazarus when I came across a
>> couple of
>> functions from the windows unit. Can anyone help me finding the
>> platform
>> independent alternatives?
>>
>> TerminateThread
>
> You shouldn't use it, generally speaking.

 You're right, I rewrote it so it doesn't use threads anymore. Thanks
 anyway.

 Regards, Darius
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Platform independent alternatives

leledumbo
Administrator
In reply to this post by Darius Blaszyk
Rewrite the threading code with FPC one (i.e. BeginThread - EndThread, or the more beautiful TThread). WaitForSingleObject... I've never used this, perhaps SyncObjs and its critical section handler? CloseHandle: depending on how you open it, close with its correct pair.
Reply | Threaded
Open this post in threaded view
|

Re: Platform independent alternatives

Fabio Luis Girardi
Some years ago, I started the port of my project (PascalSCADA) from
Windows to others platforms. I found some issues doing this. I used
all resources that the FPC RTL can offer.

To thread, I used TThread class. The issues that I found porting this,
is that Suspend/Resume don't works on others platforms than Windows.
So I rewrite my code to don't use this.

Windows messages was replaced by a class that I created to exchange
messages between threads, not process.

TCriticalSection worked as expected on all platforms, except because
it isn't a recursive mutex on unix, like it's on Windows. Again, a
little code change to avoid problems.

TEvent works as expected on all platforms since FPC 2.4.x. How it was
fixed only on FPC 2.4 version AND I want support FPC 2.2.x series, I
created my own class of Event, based on changes of TEvent class of
FPC.

Now my project works fine at least on Windows, Linux and FreeBSD,
using the thread support of FreePascal.

I avoided to use advanced resources of threading of each OS to keep my
project more platform independently as possible. Functions as
WaitForSingleObject I'm avoiding to use.


The best regards,

Fabio


2011/6/24 leledumbo <[hidden email]>:

> Rewrite the threading code with FPC one (i.e. BeginThread - EndThread, or the
> more beautiful TThread). WaitForSingleObject... I've never used this,
> perhaps SyncObjs and its critical section handler? CloseHandle: depending on
> how you open it, close with its correct pair.
>
> --
> View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Platform-independent-alternatives-tp4518482p4521676.html
> Sent from the Free Pascal - General mailing list archive at Nabble.com.
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Platform independent alternatives

Burkhard Carstens-3
Am Freitag, 24. Juni 2011 19:55 schrieb [hidden email]:

> Some years ago, I started the port of my project (PascalSCADA) from
> Windows to others platforms. I found some issues doing this. I used
> all resources that the FPC RTL can offer.
>
> To thread, I used TThread class. The issues that I found porting
> this, is that Suspend/Resume don't works on others platforms than
> Windows. So I rewrite my code to don't use this.
>
> Windows messages was replaced by a class that I created to exchange
> messages between threads, not process.
>
> TCriticalSection worked as expected on all platforms, except because
> it isn't a recursive mutex on unix, like it's on Windows. Again, a
> little code change to avoid problems.
>
> TEvent works as expected on all platforms since FPC 2.4.x. How it was
> fixed only on FPC 2.4 version AND I want support FPC 2.2.x series, I
> created my own class of Event, based on changes of TEvent class of
> FPC.
>
> Now my project works fine at least on Windows, Linux and FreeBSD,
> using the thread support of FreePascal.
>
> I avoided to use advanced resources of threading of each OS to keep
> my project more platform independently as possible. Functions as
> WaitForSingleObject I'm avoiding to use.
>

This sounds very familiar.
.. the only thing I really miss is the WaitForMULTIPLEObjects ..

b.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal