Re: ssax thread-safe? example

Bruce Butterfield <bab-lsrMmtCsshhWk0Htik3J/[email protected]> Tue, 16 Dec 2003 08:54:12 -0800
Newsgroups gmane.lisp.scheme.ssax-sxml
Message-ID <[email protected]>
That was it. Thanks so much for pointing this out -- the words 'static 
buffer' kind of stand out, don't they? Works like a champ now.

Joerg F. Wittenberger wrote:
> Hello Bruce,
> 
> Disclaimer: I'm _not_ activily using the SSAX parser.  So please
> forvige me, if I'm citeing old code here.
> 
> Bruce Butterfield <bab-lsrMmtCsshhWk0Htik3J/[email protected]> writes:
> 
> 
>> filename="threadtest.ss"
>>
>>(require (lib "thread.ss")
>>         (lib "date.ss")
>>         (lib "ssax.ss" "ssax")
>>         (lib "myenv.ss" "ssax")
>>         (lib "input-parse.ss" "ssax")
> 
> 
>>From input-parse.scm
> 
> ; Procedure input-parse:init-buffer
> ; returns an initial buffer for next-token* procedures.
> ; The input-parse:init-buffer may allocate a new buffer per each invocation:
> ;	(define (input-parse:init-buffer) (make-string 32))
> ; Size 32 turns out to be fairly good, on average.
> ; That policy is good only when a Scheme system is multi-threaded with
> ; preemptive scheduling, or when a Scheme system supports shared substrings.
> ; In all the other cases, it's better for input-parse:init-buffer to
> ; return the same static buffer. next-token* functions return a copy
> ; (a substring) of accumulated data, so the same buffer can be reused.
> ; We shouldn't worry about new token being too large: next-token will use
> ; a larger buffer automatically. Still, the best size for the static buffer
> ; is to allow most of the tokens to fit in.
> ; Using a static buffer _dramatically_ reduces the amount of produced garbage
> ; (e.g., during XML parsing).
> (define input-parse:init-buffer
>   (let ((buffer (make-string 512)))
>     (lambda () buffer)))
> 
> ...
> 
> So you might want to make sure that there is something alon the lines
> of:
> 
> (define input-parse:init-buffer
>   (lambda () (make-string 512)))
> 
> in your code.
> 
> best regards
> 
> /J?rg
> 


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click