---
name: "TSContThreadAffinitySet"
section: "3ts"
platform: "linux"
package: "trafficserver-dev"
version: "9.2.5+ds-0+deb12u4"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/TSContThreadAffinitySet"
---

# TSContThreadAffinitySet(3ts)

TSContThreadAffinitySet API function

## NAME

TSContThreadAffinitySet - TSContThreadAffinitySet API function

## SYNOPSIS

```
#include <ts/ts.h>
```

- ***TSReturnCode* TSContThreadAffinitySet(*TSCont* contp, *TSEventThread* ethread)**

  ## DESCRIPTION

Set the thread affinity of continuation *contp* to *ethread*. Future calls to *TSContSchedule()*, and *TSContScheduleOnPool()* that has the same type as *ethread* will schedule the continuation on *ethread*, rather than an arbitrary thread of that type.

*TSContSchedule()* and *TSContScheduleEvery()* will default the affinity to calling thread when invoked without explicitly setting the thread affinity.

## RETURN VALUES

*TS\_SUCCESS* if thread affinity of continuation *contp* was set to *ethread*, *TS\_ERROR* if not.

## COPYRIGHT

2026, dev@trafficserver.apache.org
