---
name: "CK_COHORT_TRYLOCK"
section: "3"
platform: "linux"
package: "libck-dev"
version: "0.7.2-6"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/CK_COHORT_TRYLOCK"
---

# CK\_COHORT\_TRYLOCK(3)

try to acquire cohort lock

## NAME

**CK\_COHORT\_TRYLOCK** – try to acquire cohort lock

## LIBRARY

Concurrency Kit (libck, -lck)

## SYNOPSIS

**#include \<ck\_cohort.h\>**

**CK\_COHORT\_TRYLOCK**(*COHORT\_NAME cohort\_name*, *COHORT \*cohort*, *void \*global\_trylock\_context*, *void \*local\_trylock\_context*, *void \*lock\_unlock\_context*);

## DESCRIPTION

This call attempts to acquire both the local and global (if necessary) locks from *cohort*. It can only be used with cohort types that were defined using the [CK\_COHORT\_TRYLOCK\_PROTOTYPE(3)](/CK_COHORT_TRYLOCK_PROTOTYPE/3.md) macro.  The call will not block and will return a bool that will evaluate to true iff the cohort was successfully acquired. *global\_trylock\_context* will be passed as the second argument to the function that was provided as the *global\_trylock\_method* argument to CK\_COHORT\_TRYLOCK\_PROTOTYPE if that method is called, and *local\_trylock\_context* will be passed to the function specified by *local\_trylock\_method*. If the global lock acquisition fails, then the cohort will immediately release its local lock as well, and *local\_unlock\_context* will be passed to the function specified by *local\_unlock\_method* when this call is made.

## SEE ALSO

[ck\_cohort(3)](/ck_cohort/3.md), [CK\_COHORT\_PROTOTYPE(3)](/CK_COHORT_PROTOTYPE/3.md), [CK\_COHORT\_TRYLOCK\_PROTOTYPE(3)](/CK_COHORT_TRYLOCK_PROTOTYPE/3.md), [CK\_COHORT\_INSTANCE(3)](/CK_COHORT_INSTANCE/3.md), CK\_COHORT\_INITIALIZER(3), [CK\_COHORT\_INIT(3)](/CK_COHORT_INIT/3.md), [CK\_COHORT\_LOCK(3)](/CK_COHORT_LOCK/3.md), [CK\_COHORT\_UNLOCK(3)](/CK_COHORT_UNLOCK/3.md), CK\_COHORT\_LOCKED(3),

Additional information available at http://concurrencykit.org/
