[Lazarus] Help on Threading and Synapse

Rimmert Ooink lazarus at ooink.net
Sat Dec 29 16:18:53 CET 2012


Hello All,

I'm working on a little client server program, and i could use a little
help on the threading/synapse model i'm working on.

I have a synapse socket in a thread that only listens for incoming
connections. When there is an incoming connection it accepts it and creates
a class (TConnection) containing the client socket.

I have a threadpool with threads that should call a method (DoWork) on the
TConnection that do the actual reading / writng on the client socket.

Now my question:

Currently all threads in the threadpool are constantly calling the
TConnection to see if there is waiting data. This makes no sense.

How would you guys solve this?


I was thinking about a second thread, which only does one thing: constantly
loop all the TConnections to see if there is waiting data, and ifso, put it
on a todo-list. This way the actual workers could all go to sleep until
there is work on the todo-list. Does this make any sense?

I hope I make any sense in my mail :-)
Anyone willing to give some advice?

Regards,
Rimmert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20121229/1e6197a9/attachment-0002.html>


More information about the Lazarus mailing list