<!--
{
  "availability" : [
    "DriverKit: -",
    "iOS: -",
    "iPadOS: -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "DriverKit",
  "identifier" : "/documentation/DriverKit/IODataQueueDispatchSource/SetDataServicedHandler",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "DriverKit"
    ],
    "preciseIdentifier" : "c:@S@IODataQueueDispatchSource@F@SetDataServicedHandler#*$@S@OSAction#"
  },
  "title" : "SetDataServicedHandler"
}
-->

# SetDataServicedHandler

Installs the handler block to execute when data is removed from the queue.

```
virtual kern_return_t SetDataServicedHandler(OSAction *action);
```

## Parameters

`action`

The [`OSAction`](/documentation/DriverKit/OSAction) object that contains the callback method to execute. The data queue retains your action object until you install a new handler or cancel the dispatch source. The system executes your callback on the dispatch queue you designated in your [`OSAction`](/documentation/DriverKit/OSAction) object.

## Return Value

[`kIOReturnSuccess`](/documentation/DriverKit/kIOReturnSuccess) on success, or another value if an error occurs. See [Error Codes](/documentation/DriverKit/error-codes).

## Discussion

If your code produces data for the queue, use this method to install a handler so you can add more data to the queue. When space becomes available in the queue, the system executes your handler.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)