Re:RE: Puzzled at callback routine Squid is using.

From: <maer727@dont-contact.us>
Date: Fri, 19 Apr 2002 20:58:11 +0800 (CST)

Thanks, Rob pal!

I still have a question, what means "side effects" and the
abbreviation "epilog"?

Best regards,
George, Ma

----- Original Message -----
From: Robert Collins
To: maer727@sohu.com
Cc: squid-dev@squid-cache.org
Subject: RE: Puzzled at callback routine Squid is using.
Sent: Fri Apr 19 20:40:30 CST 2002

>
> A normal function call:
>
> client_code ()
> {
> .. prolog
> result = foo();
> .. epilog
> }
>
> foo() executes immediately, all side effects have happened when foo
> returns.
> if foo blocks, the entire program blocks (unless threads are used).
>
> a callback function call:
>
> client_code_prolog()
> {
> .. prolog
> foo(&client_code_epilog, state_variable);
> }
>
> client_code_epilog( state_variable_type *, result_type result)
> {
> ... epilog
> }
>
> foo() executes before calling client_code_epilog, and all sideeffects
> have occurred before client_code_epilog is called. However if foo needs
> to perform a blocking activity, it registers that with the OS in some
> fashion, rather than actually blocking, and returns back to
> client_code_prolog.
>
> So the call graph looks like this for a needs-to-do-blocking call:
>
> client_code_prolog
> foo
> (foo_prolog occurs)
> register with OS
>
> .....
>
> select/poll/event - some OS wakeup mechanism
> foo_epilog
> client_code_epilog
>
> For a foo() where no blocking needs to occur, the call graph is
>
> client_code_prolog
> foo
> client_code_epilog
>
>
> I hope this helps.
>
> Rob
Received on Fri Apr 19 2002 - 06:58:42 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:15:13 MST