• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Threads and unintended message forwarding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Threads and unintended message forwarding


  • Subject: Threads and unintended message forwarding
  • From: email@hidden
  • Date: Wed, 2 Oct 2002 08:15:51 -0500

I'm having a problem where a message to an object is being fowarded to another thread, then passed to that object, instead of being passed to the object directly on the calling thread. I'm completely puzzled by this since I had thought message forwarding was only done by NSProxy/NSDistantObject/NSConnection, and the object (and instance of my class TextDocument) that is the receiver of the message is a descendant of NSDocument.

Unfortunately, it is crucial that the message *not* be forwarded: I am trying to synchronize two different threads using NSLock. The NSLock object is held by the TextDocument object.

The method in which the unintended forwarding occurs:

in class GPrologAdaptor:
- (int) readFromDocument:(void*) inDocument toCString:(char*) inCString withMaxLength:(int) inMaxLength
{
NSString * string;

[mProxy readFromDocumentToStoredString:inDocument withMaxLength:inMaxLength];
NSLog(@"read from document to stored string.");

string = [(TextDocument*)inDocument storedString]; // storedString waits until there has been a read.


[string getCString:inCString];
return [string length];
}

The forwarding occurs when "string = [(TextDocument*)inDocument storedString];" is executed. Instead of evaluating the storedString method on thread 2 (the calling thread that is evaluating 'readFromDocument:toCString:withMaxLength:'), the message is forwarded to thread 1 (the main thread on which the controller is running and on which inDocument was created).

Is there some kind of "auto-forwarding" mechanism in ObjectiveC? Does the "thread on which the object is created" control the thread on which messages to that object are evaluated?

Thanks,
Lindsey Spratt.
http://homepage.mac.com/lspratt
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Subclassing NSMutableAttributedString
  • Next by Date: Open recent documents
  • Previous by thread: Re: Alphabetizing an array
  • Next by thread: Open recent documents
  • Index(es):
    • Date
    • Thread