• 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
Re: Threading!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threading!


  • Subject: Re: Threading!
  • From: Chris Purcell <email@hidden>
  • Date: Wed, 20 Mar 2002 00:32:38 +0000

I _believe_ the word you are looking for is "oneway", as in

- (oneway void)myMethod;

Look it up in Apple's book on Cocoa:

http://developer.apple.com/techpubs/macosx/Cocoa/ObjectiveC/4MoreObjC/Remote_Messaging.
html

and search for the word "oneway"

Kritter out

There are clearly still huge gaps in my understanding of how threading
works in Cocoa.

In my app, I have set up almost exactly what is described here:

http://developer.apple.com/techpubs/macosx/Cocoa/TasksAndConcepts/ProgrammingTopics/
Multithreading/Tasks/connections.html

There's a main thread for handling the GUI, and a worker thread sitting
in a runloop. I can call methods in both directions, it all works fine.

But when the main thread calls a method on the worker thread via the
NSConnection, it _waits_ for it to return, which defeats the whole
purpose of threading in the first place. What's the point of detaching
a thread if it runs synchronously?

Specifically, here's what I'm trying to accomplish...

- A main thread, servicing the GUI

- One or more child threads, each managing a single network connection
using blocking socket calls.

For example, imagine a document-based app where each document window has
a persistent network connection associated with it. I want the document
(in the main thread) to tell its associated child network thread to
connect to some host. I DON'T want the main thread to block waiting for
the socket connection to finish, I just want a message back later from
the child thread that it either connected or it didn't.

Furthermore, if the user indicates they want to abort the connection, I
need a way to communicate that to the thread.

I can't just use plain NSThreads and NSNotifications, because this is
not thread safe. So, I switched to NSConnection, which has given me
thread-safe message passing, but blocks until the remote call
completes. So, now I don't know what to do.

There must be someone out there that knows how to do this correctly.

Thank you,

Steven
_______________________________________________
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: Encoding BOOL Objects?
  • Next by Date: Re: Coordinate system question
  • Previous by thread: Re: Threading!
  • Next by thread: Scripting a Cocoa app
  • Index(es):
    • Date
    • Thread