> ## 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.

# PFMultiplayerSetThreadAffinityMask

> Reference for PFMultiplayerSetThreadAffinityMask, which pins internal PlayFab Multiplayer library threads to specific CPU cores using an affinity mask.

Optionally configures the processor on which internal Multiplayer library threads will run.

## Syntax

```cpp theme={null}
HRESULT PFMultiplayerSetThreadAffinityMask(  
    PFMultiplayerThreadId threadId,  
    uint64_t threadAffinityMask  
)  
```

### Parameters

**`threadId`**   [PFMultiplayerThreadId](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/enums/pfmultiplayerthreadid.md)

The type of internal Multiplayer library thread to configure processor affinity.

**`threadAffinityMask`**   uint64\_t

The affinity mask for this type of Multiplayer library thread.

### Return value

Type: HRESULT

`S_OK` if the call succeeded or an error code otherwise. The human-readable form of the error code can be retrieved via [PFMultiplayerGetErrorMessage()](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayergeterrormessage.md).

## Remarks

This method enables the title to configure the processor affinity for internal Multiplayer library threads of a given type. \
\
&#x20;This method may be called at any time before or after [PFMultiplayerInitialize()](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayerinitialize.md) and will take effect immediately. Thread processor settings are persisted across calls to [PFMultiplayerUninitialize()](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayeruninitialize.md) and PFMultiplayerInitialize(). When there are more than 64 cores present, this method always applies to processor group 0.   \
\
&#x20;In order to specify any processor, pass `PFMultiplayerAnyProcessor` as the `threadAffinityMask` parameter. This is also the default value the Multiplayer library will use if this method is never called.

## Requirements

**Header:** PFMultiplayer.h

## See also

[PFMultiplayer members](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/pfmultiplayer_members.md)\
[PFMultiplayerThreadId](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/enums/pfmultiplayerthreadid.md)


## Related topics

- [PFMultiplayerThreadId](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/enums/pfmultiplayerthreadid.md)
- [PFMultiplayerInitialize](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayerinitialize.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)
- [PFMultiplayer C/C++ API overview - PFMultiplayer.h](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/pfmultiplayer_members.md)
- [set_thread_affinity_mask](https://docs.xbox.com/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_set_thread_affinity_mask.md)
