discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Messaging across threads using NSThread


From: Riccardo Mottola
Subject: Re: Messaging across threads using NSThread
Date: Mon, 06 Apr 2009 21:48:43 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.19) Gecko/20090313 SeaMonkey/1.1.14

Hello,

in FTP (available in GAP, http://gap.nongnu.org) I do inter-thread messaging with the precise goal to have threads perform operations on the main thread GUI operations.

I set up DO between the app itself this way:
   // we set up distributed objects
   port1 = [NSPort port];
   port2 = [NSPort port];
   kitConnection = [[NSConnection alloc] initWithReceivePort:port1
                                                    sendPort:port2];
   [kitConnection setRootObject:self];
/* Ports switched here. */
   portArray = [NSArray arrayWithObjects:port2, port1, nil];
   [NSThread detachNewThreadSelector: @selector(connectWithPorts:)
                            toTarget: [FtpClient class]
                          withObject: portArray];


inside "connectWithPorts" I do:

   serverConnection = [NSConnection
           connectionWithReceivePort:[portArray objectAtIndex:0]
                            sendPort:[portArray objectAtIndex:1]];
serverObject = [self alloc];
   [(id)[serverConnection rootProxy] setServer:serverObject];
   [serverObject release];
[[NSRunLoop currentRunLoop] run];


at this point DO is set up,

when the FtpClient class calls the controller, it will invoke its methods on the main thread.

It works for me both on Unix as on Windows.

Riccardo

Samantha Rahn wrote:
Does anyone have an example or a suggestion for implementing
inter-thread messaging using
performSelector:onThread:withObject:waitUntilDone:?  I am finding that
the implementation fails under windows and would like to see a working
example or any suggestions on how to make it work.

Any suggestions would be appreciated.
Sam


_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnustep






reply via email to

[Prev in Thread] Current Thread [Next in Thread]