• 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
Cocoa threading, objects by reference, and the keyword "oneway"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cocoa threading, objects by reference, and the keyword "oneway"


  • Subject: Cocoa threading, objects by reference, and the keyword "oneway"
  • From: Miguel Morales <email@hidden>
  • Date: Tue, 5 Jun 2001 16:36:48 -0700

Hello all,

I'm having a threading problem that is driving me nuts, and I was wondering if any of the Obj-C jockeys out there could help me out.

What I want to do is transfer an object from one thread to another, but only using it's reference so that I don't incur the cost of pushing the whole object through the NSConnection. I am looking for Gamma Ray Bursts, and I have a picture of the sky contained in an object (~30Mbytes in size and called SkyMap), and I want to transfer this object from one thread to another (I have a chain of threads that all do some processing and pass the object on). Now my threads are completely independent, and I would like to pass the SkyMap object's memory location since that is all I need.

I've tried to do this by following the hint in "Object-Oriented Programming and the Objective-C Language" and coding the following:

in Thread1:
... lots of code ...
SkyMapInThread1 = [[SkyMapClass alloc] init];
...
[ProxyToThread2 sendMap: &SkyMapInThread1];
... being careful not to deallocate SkyMapInThread1...


in Thread2:

(oneway void)sendMap: (in SkyMapClass**) SkyMapReference
{
SkyMapClass *newSkyMap;

newSkyMap = *SkyMapReference;

[newSkyMap doSomething];

... Send it on to the next thread in exactly the same way...
}

Now if I remove the keyword oneway from the method definition, it works, but of course defeats the parallel processing that I'm trying to do. With the keyword oneway in place the method exits silently as soon as I ask the object to doSomething. My guess is that I'm not passing the reference as I intended to and some communication is still happening, and it can't happen if I use the oneway keyword. So my question has 2 parts. What in the hell am I passing if it is not the memory location of SkymapInThread1, and how do I do what I want?

Thanks in advance for your help,

-Miguel F. Morales


  • Follow-Ups:
    • Re: Cocoa threading, objects by reference, and the keyword "oneway"
      • From: Brendan Younger <email@hidden>
    • Re: Cocoa threading, objects by reference, and the keyword "oneway"
      • From: Andreas Doerr <email@hidden>
  • Prev by Date: Re: int question
  • Next by Date: NSBrowser cell highlighting
  • Previous by thread: Problems with CurrencyConverter...
  • Next by thread: Re: Cocoa threading, objects by reference, and the keyword "oneway"
  • Index(es):
    • Date
    • Thread