• 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: spawing a server...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: spawing a server...


  • Subject: Re: spawing a server...
  • From: "Brian O'Brien" <email@hidden>
  • Date: Wed, 9 Feb 2005 12:23:43 -0700


On Feb 9, 2005, at 11:02 AM, Brian O'Brien wrote:

I want to spawn a communications server in main.mm

MyServer s;
datatype ourDataQueue;

int main(int argc, char *argv[])
{
try
{
s.start(ourDataQueue);
return NSApplicationMain(argc, (const char **) argv);
}
catch (const char *msg)
{
printf("%s\n", msg);

-1);
}
}

The idea here is that the server start method is a non blocking and
the server puts data into the dataQueue. (And then notifies its parent
thread that new data has arrived.. how I'm not sure yet.)

My question are:

I could have the start method do a fork/exec but is there a preferred
method such as a thread for Cocoa development? (Pointers please).

If a thread is spawned and places data into the queue then is there
any issues regarding a different thread accessing the queue?

Inter thread communications... Is there a Cocoa way?



I found this link on apples web site...
http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/articles/CocoaDetaching.html#//apple_ref/doc/uid/20000738/123529


However I'm confused... (Not unusual)

I call this:
<x-tad-bigger>[NSThread detachNewThreadSelector:@selector(MyThreadRoutine:) toTarget:[MyCustomClass class] withObject:nil];
to start the thread.

This goes in the .m file?

@implementation MyClass
+ (void) MyClassThreadMethod:(id)anObject;
- (void) MyInstanceThreadMethod:(id)anObject;
@end
</x-tad-bigger>


shouldn't that go in the .h file?




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >spawing a server... (From: "Brian O'Brien" <email@hidden>)

  • Prev by Date: Re: Do I need to use Distributed Objects or not?
  • Next by Date: Re: Statically linking *Obj-C* lib
  • Previous by thread: spawing a server...
  • Next by thread: Re: spawing a server...
  • Index(es):
    • Date
    • Thread