[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem with NSConnection and NSThread
From: |
richard |
Subject: |
Re: problem with NSConnection and NSThread |
Date: |
Tue, 7 Nov 2000 14:45:21 +0000 |
On Tuesday, November 7, 2000, at 01:51 PM, cornils@mail.desy.de wrote:
> Dear subscribers,
>
> I'm having problems in using remote objects (via NSConnection) from
> within newly created threads (NSThread). Some code to illustrate the
> problem:
>
> // ----------
> // initialize the connection to the server
> // This method connects to the server process on a remote host
> // and stores a reference to the (remote) vended object.
>
> [connectionController initConnection];
>
>
> // now use the remote object
> // Invoke a method of the remote object (receiving app doesn't
> // call back our sending app).
>
> [connectionController performRemoteTask:nil];
>
> // ok, works as expected
>
>
> // now try to use the remote object from a new thread
> // Same as obove except the thread.
>
> [NSThread detachNewThreadSelector:@selector(performRemoteTask:)
> toTarget:connectionController withObject:nil];
>
> // raises exception:
> // NSPortTimeoutException: timed out waiting for reply
>
> // ----------
>
> My setup: Linux/ix86, gcc 2.95.2 with patched libobjc (NSLock problem),
> GNUstep snapshot-20001107 (make and base).
>
> What am I doing wrong? Any hints are highly appreciated.
Hmm - my problem is that I'm not sure what the expected behavior is - my
understanding
is/was that connections are basically per-thread entities - certainly runloops
are.
When the connection is created, it will add its receiving port to the runloop
of the
current thread - so messages for that connection will be recieved in that
thread.
When you send to the proxy to the remote object in another thread, the outgoing
message will be sent, but the runloop in that thread won't be listening for any
response,
so you get the NSPortTimeoutException.
That explains the symptoms - but doesn't get any closer to deciding how it
should behave.