Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Guidance for doing USB reads on a separate thread



Hi Juan:

I have had similar problems in the past and the way I resolved it was to initialize the USB(open ports, configure device, etc.) from the main program and spawn a thread when I needed to read a USB pipe and write the data to a file. If you are calling a lot of methods from within the thread, make sure they don't overload the stack (I learned that one the hard way). This should free the system to enable the user to do other things. HTH.

Mike Krugman
On Apr 27, 2005, at 5:36 PM, Juan Pablo Pertierra wrote:

Hello,

Right now my cocoa application can read from the USB port and do exactly what i need it to do, except for the fact that while it is reading from the USB port everything else freezes, waiting to return from the RunLoop. I have based my USB code on the USB SImpleExample. In the end I want it to read from the USB port and write what is read to a file, while the user can still perform some simple functions on the UI of the application.

So, first of all, is there any way to add the ReadAsync notifications to the cocoa application's RunLoop without explicitly having to call CFRunLoop and wait for it to return? It seems that the cocoa application must already have it's own runloop?

If not, i'm thinking I need to just fire up another thread to do all the USB reading/writing to disk. I know the basics of NSThread, but I am unsure how to mix the USB code with a new thread. Should all the USB initialization be done on the separate thread, or can I initialize the USB(open ports, configure device, etc) on the main program and then just spawn the thread when I need to read?

I'm sure this has been done before, so generally how should I do this?

Thanks,
Juan

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Usb mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden
References: 
 >Guidance for doing USB reads on a separate thread (From: Juan Pablo Pertierra <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.