---
title: SetDataServicedHandler
framework: driverkit
role: symbol
role_heading: Instance Method
path: driverkit/iodataqueuedispatchsource/setdataservicedhandler
---

# SetDataServicedHandler

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

## Declaration

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

## Parameters

- `action`: The doc://com.apple.driverkit/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 doc://com.apple.driverkit/documentation/DriverKit/OSAction object.

## Return Value

Return Value kIOReturnSuccess on success, or another value if an error occurs. See Error Codes.

## Discussion

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.

## See Also

### Adding Work to the Queue

- [DataServiced](driverkit/iodataqueuedispatchsource/dataserviced.md)
- [Enqueue](driverkit/iodataqueuedispatchsource/enqueue.md)
- [EnqueueWithCoalesce](driverkit/iodataqueuedispatchsource/enqueuewithcoalesce.md)
- [SendDataAvailable](driverkit/iodataqueuedispatchsource/senddataavailable.md)
- [IODataQueueClientEnqueueEntryBlock](driverkit/iodataqueueclientenqueueentryblock.md)
