Recent

Author Topic: Question on crossplatform signalling between threads  (Read 3951 times)

stab

  • Full Member
  • ***
  • Posts: 234
Question on crossplatform signalling between threads
« on: June 18, 2010, 07:51:42 am »
Hi all,

Some days ago I sent a question on crossplatform communication and was adviced to use critical sections. Thats seems good and I plan to use some kind of queueing to exchange messages between threads.
One thing I'm wondering about is how to signal that one thread has added a message to a shared message-queue in a crossplatform way that does not include polling.

In windows I've handled inter-thread communication through windows-messages. Is there something similar that could be used on other platforms or how could one achieve this signalling in a safe and efficient way?

Regards
Staffan %)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Question on crossplatform signalling between threads
« Reply #1 on: June 21, 2010, 07:48:00 pm »
AFAIK messaging (SendMessage and PostMessage) is supported on all LCL platforms, so you can use that safely.

stab

  • Full Member
  • ***
  • Posts: 234
Re: Question on crossplatform signalling between threads
« Reply #2 on: June 22, 2010, 12:04:14 pm »
Thanks a lot Leledumbo.

Excellent, that the Lazarus-team have made SendMessage and PostMessage cross-platform.

Is PostThreadMessage also OK to use cross-platform?

Have been pondering for some days already how I could build some kind of messaging system, windows-like, by myself and you guys have already fixed it for me.

Excellent job.

One thing that I don't get to work is the debugger:

OS: Windows XP svp 3
Lazarus: 0.9.28.2 beta
FPC: 2.2.4
SVN version: 22279

I have tried to set debugger through:

Environment --> Options --> Debugger --> General
and specified:
GNU debugger (gdb) as C:\lazarus\mingw\bin\gdb.exe

If I just try to run an app, that is working fine without debugger set,
even without setting a single breakpoint stops immedately with:
Project XX.exer raised exception class 'External: SIGSEGV'

Is there something else that sholud be set or done before using the debugger than what I've specified above?

Have tried to get along with adding showmessage at distinct point in the code but that is of course not a sufficient solution especially when coming from Delphi.

Any suggestions on how to get the debugger to work is appreciated

Regards

Staffan %)

 

TinyPortal © 2005-2018