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?


In reply to Make Current State Known by pileofrogs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.