Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
My goal is to create a Python module for document scanning. What I want to do is allow a Python program to grab a list of scanner devices and present them to the user. Unfortunately, ICDeviceBrowser uses delegation to post whatever scanner devices it sees. I believe people who use my Python module to find scanners will want to be able to call a Python function that returns the list. So, I believe that means I need to create a C++ function that does exactly that.

Since ICDeviceBrowser's delegate protocol's didAddDevice method has a moreComing BOOL, I'm thinking of giving my C++ class a moreComing bool property and having it run a loop until that bool is set to "true"
 
I think wrapping an asynchronous (non-blocking) call in a synchronous (blocking) call is rarely a good idea.

There's typically a good reason why the asynchronous call is asynchronous in the first place - usually because it takes some time to execute and would otherwise block that thread. If you wrap that call in a loop that could block the thread too.

If possible, could you try pre-fetching the list of devices when your module is initialised and caching that list, so when the function to list them is called you can return it immediately? It might mean the device list is slightly out of date, but perhaps that's a worthwhile compromise for not blocking the thread.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.