Jonathan,
The reason I need to thread is not anything to do with AsyncSocket, which is
an excellent library that does not block.  I have several time consuming
operations that must occur sequentially.  These sequences need to run
(start/stop) asynchronous of each other, so I want these to run in separate
execution threads.

The "old school" way that I used to manage multiple asynchronous sequences
like this was to use complex state machines, but I am sure that you will
agree that separate threads is certainly the way to go.

I am just having difficulty getting my head around the run loop in the
worker threads.  I have also tried the ThreadWorker library, that although
has some awesome features, does not let my AsyncSocket objects run properly.

And thanks, I appreciate any and all feedback,

Matt

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, August 14, 2008 5:04 PM
To: cocoa-dev@lists.apple.com
Subject: Re: Threading problem using AsyncSocket (Matthew Youney)

I don't know about your threading problem but surely the whole point
of AsyncSocket is the Async bit.
It is designed to attach itself to the runloop and remove the need for
blocking sockets etc on threads.

I use AsyncSocket extensively within the main thread and it can handle
multiple connection without any problem.


> Hello list,
> This is my first attempt at threading with Cocoa, and I am having
> difficu=
> lty
> with my classes that use AsyncSocket.  I am using
> DetachNewThreadSelector=
> :
> to detach my =91worker=92 thread, and I am instantiating my class
> that us=
> es
> AsyncSocket from within this thread.  The problem is that the
> AsyncSocket
> delegates are never called.  This class works just fine from the main
> thread.
>
> - (IBAction)RunTestButtonPressed:(id)sender
> {
>            [NSThread detachNewThreadSelector:
> @selector(threadFunction:)
> toTarget: self withObject: recipe];
> }
>
>
> - (void) threadFunction:(BeverageRecipe*)recipe
> {
> ClassContainingAsyncSocket* foo;
> int i=3D0;
>
>            while (stuffTodo)
>            {
> NSAutoreleasePool* autoReleasePool=3D[[NSAutoreleasePool alloc]init];
>
>            foo=3D[[ ClassContainingAsyncSocket alloc]init];
>
>            i=3D[foo readRegister:0];  //none of the AsyncSocket
> delegate=
> s
> =91fire!=92
>
>            [autoReleasePool release];
>
>
> do more stuff=85.
>            }
>
> }
>

Does anyone have any idea what I am missing?  Something fundamentally
wro=
ng?
Thanks in advance for any and all assistance.

Matt
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/matt%40youney.com

This email sent to [EMAIL PROTECTED]


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to