Sign in Join

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

Mailing lists / lazarus / 2012-12

Help on Threading and Synapse

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

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

Rimmert Ooink

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.freepascal.org/pipermail/lazarus/attachments/20121229/1e6197a9/attachment.html>

Reply by email