*
*/
+#define IOKIT_ENABLE_SHARED_PTR
+
#include <IOKit/IOCommandPool.h>
+#include <libkern/c++/OSSharedPtr.h>
#define super OSObject
OSDefineMetaClassAndStructors(IOCommandPool, OSObject);
// withWorkLoop - primary initializer and factory method
//--------------------------------------------------------------------------
-IOCommandPool *
+OSSharedPtr<IOCommandPool>
IOCommandPool::
withWorkLoop(IOWorkLoop *inWorkLoop)
{
- IOCommandPool * me = new IOCommandPool;
+ OSSharedPtr<IOCommandPool> me = OSMakeShared<IOCommandPool>();
if (me && !me->initWithWorkLoop(inWorkLoop)) {
- me->release();
- return 0;
+ return nullptr;
}
return me;
return false;
}
- if (kIOReturnSuccess != inWorkLoop->addEventSource(fSerializer)) {
+ if (kIOReturnSuccess != inWorkLoop->addEventSource(fSerializer.get())) {
return false;
}
// commandPool & init - obsolete initializer and factory method
//--------------------------------------------------------------------------
-IOCommandPool *
+OSSharedPtr<IOCommandPool>
IOCommandPool::
commandPool(IOService * inOwner, IOWorkLoop *inWorkLoop, UInt32 inSize)
{
- IOCommandPool * me = new IOCommandPool;
+ OSSharedPtr<IOCommandPool> me = OSMakeShared<IOCommandPool>();
if (me && !me->init(inOwner, inWorkLoop, inSize)) {
- me->release();
- return 0;
+ return nullptr;
}
return me;
// remove our event source from owner's workloop
IOWorkLoop *wl = fSerializer->getWorkLoop();
if (wl) {
- wl->removeEventSource(fSerializer);
+ wl->removeEventSource(fSerializer.get());
}
- fSerializer->release();
- fSerializer = 0;
+ fSerializer.reset();
}
// Tell our superclass to cleanup too
// waiting for resources
//--------------------------------------------------------------------------
-IOCommand *
+OSSharedPtr<IOCommand>
IOCommandPool::getCommand(bool blockForCommand)
{
IOReturn result = kIOReturnSuccess;
- IOCommand *command = 0;
+ IOCommand *command = NULL;
IOCommandGate::Action func = OSMemberFunctionCast(
IOCommandGate::Action, this, &IOCommandPool::gatedGetCommand);
result = fSerializer->
runAction(func, (void *) &command, (void *) blockForCommand);
if (kIOReturnSuccess == result) {
- return command;
+ return OSSharedPtr<IOCommand>(command, OSNoRetain);
} else {
- return 0;
+ return NULL;
}
}