> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SetCpuAffinity

> IDStorageFactoryX::SetCpuAffinity

Sets a CPU affinity mask for DirectStorage.

## Syntax

```cpp theme={null}
HRESULT SetCpuAffinity(  
         UINT64 affinity  
)  
```

### Parameters

*affinity*\
Type: UINT64

The CPU affinity mask.

### Return value

Type: HRESULT

Standard HRESULT error code.

## Remarks

DirectStorage normally performs work in the calling thread. However, some work can't be performed in the calling thread. To restrict such work to a specified set of CPU cores, set a CPU affinity mask.

For more information, see "SetCPUAffinity" in the "IDStorageFileX" section in [DirectStorage Overview](https://docs.xbox.com/build/console-features/storage/directstorage/directstorage-overview.md).

## Requirements

**Header:** dstorage\_xs.h

**Library:** dstorage\_xs.lib

**Supported platforms:** XBOX Series consoles

## See also

[IDStorageFactoryX](https://docs.xbox.com/reference/system/dstorage/interfaces/IDStorageFactoryX/idstoragefactoryx.md)\
[DStorage](https://docs.xbox.com/reference/system/dstorage/dstorage_members.md)


## Related topics

- [IDStorageFactoryX (Interface contents)](https://docs.xbox.com/reference/system/dstorage/interfaces/IDStorageFactoryX/idstoragefactoryx.md)
- [Game Performance in Hybrid CPU Environments](https://docs.xbox.com/build/gdk-and-engines/guides/hybrid-cpu-performance.md)
- [PFMultiplayerSetThreadAffinityMask](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayersetthreadaffinitymask.md)
- [DirectStorage Overview](https://docs.xbox.com/build/console-features/storage/directstorage/directstorage-overview.md)
- [Asynchronous Lobby and Matchmaking C++ SDK operations and notifications](https://docs.xbox.com/services/playfab/multiplayer/lobby/lobby-and-matchmaking-client-sdk-async.md)
