> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.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](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/enums/pfmultiplayerthreadid)

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()](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayergeterrormessage).

## Remarks

This method enables the title to configure the processor affinity for internal Multiplayer library threads of a given type. <br /><br /> This method may be called at any time before or after [PFMultiplayerInitialize()](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayerinitialize) and will take effect immediately. Thread processor settings are persisted across calls to [PFMultiplayerUninitialize()](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayeruninitialize) and PFMultiplayerInitialize(). When there are more than 64 cores present, this method always applies to processor group 0.   <br /><br /> 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](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/pfmultiplayer_members)\
[PFMultiplayerThreadId](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/enums/pfmultiplayerthreadid)


## Related topics

- [PFMultiplayerThreadId](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/enums/pfmultiplayerthreadid.md)
- [PFMultiplayerInitialize](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayerinitialize.md)
- [Async Lobby and Matchmaking C++ SDK operations guide](/services/playfab/multiplayer/lobby/lobby-and-matchmaking-client-sdk-async.md)
- [PFMultiplayer C/C++ API overview - PFMultiplayer.h](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/pfmultiplayer_members.md)
- [PartyManager::SetThreadAffinityMask](/services/playfab/multiplayer/networking/reference/classes/PartyManager/methods/partymanager_setthreadaffinitymask.md)
