|Keep It Simple, Stupid|
Re: Handling asynchronous events with Perlby BrowserUk (Patriarch)
|on Jul 11, 2005 at 00:14 UTC ( #473808=note: print w/replies, xml )||Need Help??|
Your program could be as simple as:
This assumes that the inbound files are named AUVnnn.dat, with nnn representing each AUV.
You then create a separate package to process each AUV's data, that exports a single entrypoint that takes the filename to process as it's only arguement. The modules would have a consistant naming AUV::nnn, and would look something like this:
All this does it print the data to the terminal for testing.
This allows you to add and modify the processing modules without stopping the main dispather. The dispatcher will use negligable cpu while no files need processing. A file will be dispatched for processing within 1 second of it arrival. If a file arrives and it's module is unavailable, it will simply wait until the module becomes available, at which point it will be processed. The dispatcher should easily run unattended for mpnths without problems as the dispatcher uses minimal memory or processor and no memory growth. All the memory used to process the data is immediately freed back to the runtime for reuse when the thread terminates.
Add error checking, logging etc. as required.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
In Section Seekers of Perl Wisdom