[Haskell-beginners] Help me with designing my daemon, please.
michael at schmong.org
Wed Sep 7 21:31:11 CEST 2011
This is what I am trying to do.
I have tests to run and manage. I'm only running one test at a time.
When my daemon gets a signal, it will either prep a test and run it,
or queue the request. After it runs the test, I want it to check the
queue for other tests that may have been requested.
This is my first expedition into this domain. I'm trying to collect
MVars and putting tem in a TChan is the way that seemed right, but I'm
not sure at all. This is my first guess.
I thought I needed a forked thread for the eventuality that I get a
signal while my transaction is being executed.
Have I clarified or further obfuscated?
On Wed, Sep 7, 2011 at 12:22 PM, David McBride <dmcbride at neondsl.com> wrote:
> It sounds bizarre. Why pass around an mvar in tchan, when you could
> just pass a maybe around and pattern match to see if it is Nothing or
> not? Also, why have forkio and tchan at all if they are only going to
> operate in sequence, one at a time?
> What exactly are you trying to do?
> On Wed, Sep 7, 2011 at 3:01 PM, Michael Litchard <michael at schmong.org> wrote:
>> I have a daemon I need to build, and need to work out some design
>> details I am having difficulty with. Here's what the design looks like
>> right now
>> When the daemon starts it creates an empty MVar and an empty TChan.
>> Then it listens for a usrSIG1.
>> when it gets one, it checks to see if the MVar is empty. If it is, it
>> does some stuff to fill the MVar, which is then used to pass around
>> state for a list of functions. These functions are always the same.
>> After evaluating these functions, the TChan is checked. As long as the
>> TChan has something in it,
>> it populates an MVar and the same three functions are evaluated in the
>> same order again.
>> If the MVar is full, it creates another MVar of the same type and puts
>> it in the TChan.
>> Is this a sound design? Does it prompt any questions from you? Here's
>> my question. If this is basically a sound design, I know I will need
>> use forkIO. I'm not sure where.
>> If this is not a sound design, please ask questions or give other
>> feedback so I can make changes and restore sanity.
>> Beginners mailing list
>> Beginners at haskell.org
More information about the Beginners