Re: Daemonizing CRM114 using FIFO
James Lee <csejl-/[email protected]>
| Newsgroups | gmane.mail.spam.crm114 |
|---|---|
| Message-ID | <[email protected]> |
After looking at Paolo's example script, I was able to come up with the following solution to my problem:
{
isolate (:fifo:)
isolate (:chunk:)
isolate (:buffer:)
isolate (:first_result:)
# classify dummy content to load the css files so that we don't have to reinitialize repeatedly in the :do_it: function below
classify <osb unique microgroom> (\/home\/me\/css\/A.css \/home\/me\/css\/B.css \/home\/me\/css\/C.css \/home\/me\/css\/D.css) (:first_result:)
:loop:
{
input (:fifo:) [ \/tmp\/dynamic_fifo ]
# in case the entire content is too big to be delivered at once or fifo is accidently closed on the client side, put the con
tent into buffer
alter (:buffer:) /:*:buffer::*:fifo:/
{
#output /buffer = :*:buffer:\n/
window (:chunk:) /.*/ (:buffer:) /\n=>My Divider<=\n/
syscall /:do_it: >>\/home\/me\/result\/result.txt /
alter (:chunk:) //
liaf
}
liaf
}
goto /:loop:/
}
{
:do_it:
isolate (:id:)
isolate (:clean_chunk:)
isolate (:result:)
isolate (:junk1:)
isolate (:junk2:)
isolate (:category:)
match (:: :id: :clean_chunk:) /My Unique ID = ([[:digit:]]+)\n(.*)\n=>My Divider<=\n/ [:chunk:]
classify <osb unique microgroom> (\/home\/me\/css\/A.css \/home\/me\/css\/B.css \/home\/me\/css\/C.css \/home\/me\/css\/D.css) (:result:) [:clean_chunk:]
match (:: :junk1: :category: :junk2:) /(.*)file #([[:digit:]])(.*)/ [:result:]
output /:*:id:, :*:category:\n/
exit
}
BTW, the sleep/wait that I was referring to in my first email was on the client side. Using this script, you don't have to sleep or even close the FIFO anymore. If you guys see anything that I can do to make this even more efficient, please let me know. Thanks.
-James
----- Original Message ----
From: Ger Hobbelt <[email protected]>
To: James Lee <csejl-/[email protected]>
Cc: [email protected]
Sent: Monday, September 22, 2008 2:31:41 PM
Subject: Re: [Crm114-general] Daemonizing CRM114 using FIFO
Ah, I forgot: given how CRM114 works internally, and assuming your
messages are relatively large, i.e. bigger than a hundred bytes on
average, I'd go with the length+content solution, because that would
prevent CRM114 from having to perform an unknown number of 'unescape'
operations on your message content.
Since CRM114 only starts to act on the input once it is closed (i.e.
when CRM114 receives an End Of File signal), the fastest possible
operation would be that, combined with the use of 'batches', i.e.
merging multiple messages in a single open+write+close FIFO session,
while staying within the maximum data buffer size limits of CRM114
itself (which are > 1MB by default IIRC). That would mean your
result.txt
will end up containing the answers for all the messages in such a
'batch', though a bit of encoding/decoding may be required on that
side as well.
--
Met vriendelijke groeten / Best regards,
Ger Hobbelt
--------------------------------------------------
web: http://www.hobbelt.com/
http://www.hebbut.net/
mail: [email protected]
mobile: +31-6-11 120 978
--------------------------------------------------
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/