armadsen / ORSSerialPort

Serial port library for Objective-C and Swift macOS apps
MIT License
751 stars 183 forks source link

A slow response to port open.... #180

Closed gghose closed 2 years ago

gghose commented 3 years ago

I have a multi-threaded program with a lot of initialization going on. In a non-main thread I open a serial port, which presumably puts a request on the main thread. The problem it is taking a relatively long time for that request to be made (so presumably there's a lot of NIB initialization that's delaying it).

The specifics are an interval of about 3 seconds between the port open and getting the message serialPortWasOpened. Any way to speed this up?

armadsen commented 2 years ago

If I understand you correctly, the problem is not that the port actually takes a long time to open, rather than the serialPortWasOpened delegate call back takes a long time due to it waiting on other tasks going on on the main thread/queue. Assuming that's the case, the obvious solution is to reduce contention on the main queue, but I realize that's easier said than done. There is an issue for allowing a custom delegate queue to be specified: #35. I've decided not to do that for now, but may revisit in the future.