pileofrogs has asked for the wisdom of the Perl Monks concerning the following question:
I'm writing an app that has a number of attributes that can be in a whole bunch of different states. Other apps (that I'm going to write) need to know what state those attributes are in. What's the best way to make that information available to other apps?
Here's a simplified example. I have an app that makes coffee, an app that makes toast and another app that makes orange juice. It takes longer to make the coffee than to make the toast, so the toaster app wants to know how the coffee is coming along, so it can start making the toast at the right time. The orange juice app wants to know how acidic the coffee is going to be so it can choose a low acidity orange juice concentrate if the coffee is really acidic that day.
What's the best way to handle this?
(Needs to run on Linux)
Thanks!
--Pileofrogs
Update: Toast and OJ depend on coffee and know about coffee. Coffee doesn't know about toast or OJ. If I want to add scrambled eggs (and scrambled eggs depend on coffee), scrambled eggs is written with coffee in mind and coffee doesn't need to change.
Right now my favorite idea is a simple db file, like GDBM_File. Supports one writer and several readers, so there's no locking issues. The interface is super easy: just read and write to a hash.
Yet Another Update: In order for my db file idea to work, all updates need to be written to disk immediately (aka synchronously). Interestingly, GDBM_File's synchronous mode doesn't really seem to do anything. I had to tie/untie each time I wrote anything to get a synchronous behavior. MLDBM::Sync is probably a smarter way to go, but I'm out of time to spend on this part of the project...
Shared memory sounds good except I don't get how you can make it remotely secure. Can't any process write anything it wants to the shared memory?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Make Current State Known
by 5mi11er (Deacon) on Feb 10, 2006 at 21:20 UTC | |
|
Re: Make Current State Known
by saintmike (Vicar) on Feb 10, 2006 at 21:12 UTC | |
by GrandFather (Saint) on Feb 10, 2006 at 21:20 UTC | |
by saintmike (Vicar) on Feb 10, 2006 at 21:28 UTC | |
by GrandFather (Saint) on Feb 10, 2006 at 21:39 UTC | |
|
Re: Make Current State Known
by traveler (Parson) on Feb 10, 2006 at 22:25 UTC | |
by Perl_Inquiry (Initiate) on Feb 13, 2006 at 19:27 UTC | |
|
Re: Make Current State Known
by GrandFather (Saint) on Feb 10, 2006 at 21:14 UTC | |
|
Re: Make Current State Known
by Anno (Deacon) on Feb 14, 2006 at 11:15 UTC |