This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Wed, 2003-03-19 at 21:56, Thomas Pfaff wrote: > I think that the code could be simplified by making callback a pointer to > member function. > > void forEach (void (ListNode::*callback) ()) > { > ListNode *aNode = head; > while (aNode) > { > (aNode->*callback) (); > aNode = aNode->next; > } > } > > With this change you do not need a static to member wrapper function like > pthread_key::saveAKey. > > You could write > > void pthread_key::fixup_before_fork() > { > keys.forEach (&pthread_key::saveKeyToBuffer); > } > > void pthread_key::fixup_after_fork() > { > keys.forEach (&pthread_key::recreateKeyFromBuffer); > } > > void pthread_key::runAllDestructors () > { > keys.forEach (&pthread_key::runDestructor); > } > > instead. For some reason, I forgot that I put in the 'poor mans generic programming' initially. It just stood out in the patch. Using a member pointer like that still requires each function to have the same signature. The for_each I sketched below allows arbitrary callbacks like using a member function does, but computes them at compile time which allows for more efficient binary output. Please apply your patch. Rob -- GPG key available at: <http://users.bigpond.net.au/robertc/keys.txt>.
Attachment:
signature.asc
Description: This is a digitally signed message part
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |