Kalle Olavi Niemitalo <[EMAIL PROTECTED]> writes:

> > And why on earth is a function declared inside another
> > function?
> 
> I guess only Thomas Bushnell, BSG can answer that.

internal_demuxer is nested so that it has access to the local
variable DEMUXER.  We can't just pass DEMUXER in as an extra argument
to internal_demuxer, because internal_demuxer's interface is defined
by the mach_msg_server_timeout function.  In fact, this use of nested
functions is a very nice feature of GNU C, and any decent language
(like, say, Scheme), and you should learn to get used to it and even
use it in your own programs!  It makes things much cleaner overall.

thread_function is nested so that it has access to GLOBAL_TIMEOUT,
LOCAL_TIMEOUT, HOOK, and BUCKET.  We can't just extend its interface
because it's interface is defined by cthread_fork.

> And couldn't some of those parameters be grouped together in a
> struct/union, so that only the address could be passed?

That would only slow the code down and do nothing in increase
clarity. 

> And how often is this function called?

ports_manage_port_operations_multithread is called once in most
servers; some have two separate service operations going on and call
it twice.

> > suggestion: a) Move ';' to line below, so we can see it.
> 
> I once read about an interpreted C-like language which didn't
> allow empty statements like ";" -- programmers had to use an
> empty block "{}" instead.  IMHO it wouldn't hurt to do that in
> real C too.

Of course, 

do stmt while (condition) {}; 

is illegal syntax, since this is a do/while loop.  In while loops with
empty bodies, I always put the semi on a separate line for just this
reason. 

Thomas

Reply via email to