guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to call a user defined hook (written in guile) from C when


From: Cedric Cellier
Subject: Re: Best way to call a user defined hook (written in guile) from C when the hook need plenty parameters
Date: Wed, 7 Jul 2010 16:33:17 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

(resend since previous mail was not delivered)

First, let's give more details about what we are trying to implement.
The main C program is continuously measuring some realtime evolving
values, and periodically (lets say every 30 seconds) it must dump all
measurements in a CSV file. As there are many such measurements to dump
(say several tens of thousands) the dump itself must be reasonably fast
so that the measurement are not halted for too long.

Now, the C program measure an awful lot of things, and we are not always
interested in every value, and we would like to have the ability to
perform some hot reconfiguration of the CSV format in order to :

- skip entries when the measurement looks suspicious
- apply some numerical operations on individual values (for instance,
  dump the sum of two values instead of each one individually)
- reorder the fields
- etc...

That's where guile enter the stage.

Given a list of field names, the user enter (in a configuration file
or live on a socket) the list of fields (or any other scheme expressions)
he wants in the CSV file.

Every time the program wants to dump its values into a CSV file it will
loop over all the measurement and call a guile hook that must print the
required fields.

And by user I mean another in-house program so this configuration must
not be monkey proof. :)

Hope it's clearer now.

> For "a set of named values", you can use an association list.

I though of this, but I'm afraid the linear lookups in the alist would 
take too much time (we want to call the hook that write a CSV line
approx 50k times in a loop, for every dump, so getting the value of foo
should take a constant (small) time). I think (but haven't checked yet)
that the binding between arguments values and argument names is much
faster than that, since basically arguments are accessed directly by
number (the fact that argument foo is the nth argument is known at
"compile" time).

Thank you very much for your suggestion that I'm now going to study more
closely :-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]