[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]


    Search the Q&A Archives


How would I overload the message passing system such that I...

<< Back to: Objective-C FAQ

Question by John
Submitted on 6/28/2004
Related FAQ: Objective-C FAQ
Rating: Not yet rated Rate this question: Vote
How would I overload the message passing system such that I could extend the functionality of it to automatically handle swizzling of an object with proper locking for a thread safe environment?  I can handle the locking, just can't figure out how to hack the message passing functions.

It would appear as such:

void new_message_passing_code(id anObject, void *result, ...) {
  va_list *a = va_start(result);
  int lockHeld = 0;
  if (anObject)
    lockHeld = [anObject readLockAccess];
  if (lockHeld) {
    vnew_message_passing_code([anObject replacer], result, a);
  }
  else {
    old_message_passer(anObject, result, a);
  }
  va_end(a);
  if (anObject)
    [anObject unlockAccess];
}

Or something.  I don't know how the system works, but it'd look like that (with vnew_... being the same, with a va_list).

The point would be that I could lock an access lock on an object, and have a special member switch the object out for a new one and set the internal pointer for the old one to the new one; then if that switch is detected, it will redirect the message search to the new object, thus creating a thread-safe method of exchanging any object for any other object from a simple plugin interface.


Your answer will be published for anyone to see and rate.  Your answer will not be displayed immediately.  If you'd like to get expert points and benefit from positive ratings, please create a new account or login into an existing account below.


Your name or nickname:
If you'd like to create a new account or access your existing account, put in your password here:
Your answer:

FAQS.ORG reserves the right to edit your answer as to improve its clarity.  By submitting your answer you authorize FAQS.ORG to publish your answer on the WWW without any restrictions. You agree to hold harmless and indemnify FAQS.ORG against any claims, costs, or damages resulting from publishing your answer.

 

FAQS.ORG makes no guarantees as to the accuracy of the posts. Each post is the personal opinion of the poster. These posts are not intended to substitute for medical, tax, legal, investment, accounting, or other professional advice. FAQS.ORG does not endorse any opinion or any product or service mentioned mentioned in these posts.

 

<< Back to: Objective-C FAQ


[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]

© 2008 FAQS.ORG. All rights reserved.