-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Description
The asynPortDriver::connect() function is virtual. However, it is called indirectly from the constructor because asynManager::registerPort() calls it when autoConnect is true. This is a problem because the object is not fully constructed yet, so it is not possible to call an overridden connect function. This makes it more difficult for derived drivers to do connection management using asyn facilities.
I thought about different options for fixing this, but it's not possible without breaking compatibility in some way.
- Enabling autoconnect with a separate function after construction (e.g. in the iocsh command that creates the driver, or in a factory function) is the most sensible, but requires derived drivers to know to do it. Having the
autoConnectparameter toasynPortDriverconstructor is then superfluous. - Enabling autoconnect later in the constructor might work most of the time because asyn sets up a timer to fire after 10ms, and the constructor should be done by then. Hopefully. I don't like this too much.
- Enabling autoconnect from the callback thread would ensure that construction is complete. But not only does this change the behavior significantly, it also breaks when there is no IOC where it reverts to the current behavior because
interruptAcceptis always on.
So, I don't see a general solution. I guess drivers will just have to cope. At least, merging #217 would make enabling autoconnect later work.
Metadata
Metadata
Assignees
Labels
No labels