Re: Bluetooth and runloops in a dedicated thread.
Re: Bluetooth and runloops in a dedicated thread.
- Subject: Re: Bluetooth and runloops in a dedicated thread.
- From: David Giovannini <email@hidden>
- Date: Mon, 26 Apr 2010 17:43:21 -0500
Hello,
Thank you for the reply.
I can easily share a single thread between all bluetooth devices. That will solve any multi-threading issues in the bluetooth services. Bluetooth installs itself as an NSRunLoop source, somehow. IOBluetoothValidateHardware used to do that, and the NSRunLoop had kept on running.
I cannot have the BlueTooth library pick a runloop at random. Depending on configuration, this application may have a UI and/or may have a web-service. Bluetooth communications needs to be sandboxed into a designated RunLoop.
I guess the short question is-
How do I tell the Bluetooth library to install itself as a source on a specific runloop of a specific thread? If I need to start that thread in main, I'll do it!
Cheers,
Dave
On Apr 26, 2010, at 5:13 PM, Dave Keck wrote:
>> I have an old project that I am restarting, and under Snow Leopard it is
>> broke. The problem didn't have a well documented solution in older OSes. I
>> am hoping to get some guidance. I would like to have a dedicated thread for
>> every IOBluetoothDevice/IOBluetoothRFCOMMChannel pair.
>> The runloop below exits immediately. IOBluetoothValidateHardware used to
>> perform enough side-effect magic to keep the runloop running. What
>> should startBlueToothThread look like?
>
> To my knowledge, no part of the Bluetooth frameworks documentation
> says anything about thread safety, and for that reason you must assume
> that it is only safe to use from the main thread.
>
> Also, a thread's run loop will only run if it has either run loop
> sources or timers attached; the fact that NSRunLoop's -run ever
> returns means that it has neither. This is what I would expect based
> on your -startBlueToothThread: method, as it doesn't appear to create
> a source or timer. If you wanted to keep the thread alive, I would
> attach a dummy timer to the run loop that fires after some
> extraordinary amount of time. (Assuming you're not using the Bluetooth
> APIs on the thread...)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden