On Nov 3, 2006, at 12:29, Tinia wrote:


"Rocco Caputo" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
On Oct 29, 2006, at 06:11, Tinia wrote:

I'd kindly ask if anyone more experienced can give some advice where to start to get as clean as possible skeleton for such application, so they
block and eat cpu as low as possible and also have convenient way of
communicating each other...

I know I should probably read a lot of docs to get started, but I'm more
of
a example learner that digs into docs after some simple working
example....
[...]
Hi, thanks for info. I've looked at examples, but somehow got confused with
all possible ways to organize such application. I'm more interested in
getting such application organized in most efficient way - I found quite some variations how this can be done, new modules that eases some tasks are
released - so I'm just looking for currently most efficient core of
application of this kind...

The most runtime-efficient code is not the most elegant or maintainable. I don't recommend starting to use POE by writing hardcore optimized code. Rather, start simpler so you can focus on learning POE, then go back and optimize later.

First divide the program based on specific tasks. If each TCP client talks to a different service, then it would appear you have three tasks: Client 1, client 2, and serial.

Define interfaces for each task. You're on your own here, but basically: Make a list of events each task should handle. Also make a list of events each task can emit. Link output events to input events. When one task throws an event, what handler needs to be called?

At a lower level, you're going to need internal events and handlers so each task can interact with its remote resources. The TCP clients need to handle I/O events when they interact with their servers. The serial task needs to handle I/O events when it talks to its device. All of them may need timer events for timeouts and periodic maintenance tasks.

If your program is using three static sessions, then each can have an alias describing its role in the system. Sessions can throw events at those roles, and they'll arrive in the proper places.

This is all generalization. It may be completely wrong for your application. At some point you'll need to sit down and figure POE out so you can apply it the best way that fits your particular situation. Good luck.

--
Rocco Caputo - [EMAIL PROTECTED]


Reply via email to