Hi, Retain bumps a reference count and release lowers it. When a reference count drops to zero the object is removed. Calling retain() before function call and release() after is redundant and even might point to synchronization problems in the design. The idea of a reference count is that an object in use has a nonzero reference count. If a reference count drops to zero that means that the object can't be reached. This is the same idea as in garbage collectors.
On Wed, Aug 10, 2016 at 2:22 PM, Peter Zegelin <[email protected]> wrote: > Hi, > > I am making some progress on my Virtual Serial Port kernel extension which > is mainly based on AppleUSBCDCDMM example driver. I have noticed that all > calls to fCommandGate->runAction are surrounded by retain() and release() > and was wondering why this is necessary. e.g.: > > retain(); > ret = fCommandGate->runAction(acquirePortAction, (void *)sleep); > release(); > > I’ve only ever really programmed using ARC so am not that familiar with > retain and release, but the driver also calls retain() in aquirePort and > calls release() in releasePort, so wouldn’t this be enough to keep my > driver alive? > > thanks! > > Peter > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Usb mailing list ([email protected]) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/usb/slava.imameev%40gmail.com > > This email sent to [email protected]
_______________________________________________ Do not post admin requests to the list. They will be ignored. Usb mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/usb/archive%40mail-archive.com This email sent to [email protected]
