---
name: "sc_ThreadLockHolder"
section: "3"
platform: "linux"
package: "libsc-doc"
version: "2.3.1-22"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/sc_ThreadLockHolder"
---

# sc\_ThreadLockHolder(3)

Acquire a lock on creation and release it on destruction.

## NAME

sc::ThreadLockHolder - Acquire a lock on creation and release it on destruction.

## SYNOPSIS

`#include <thread.h>`

### Public Member Functions

**ThreadLockHolder** (const **Ref**\< **ThreadLock** \> &l)\
 Acquires the lock.  void **unlock** ()\
 Release the lock before the DTOR is called, if it is still held.  void **lock** ()\
 Acquire the lock once more.  **~ThreadLockHolder** ()\
 Releases the lock if it is still held.

## Detailed Description

Acquire a lock on creation and release it on destruction.

This should be used to lock and unlock **ThreadLock** objects to provide exception safety.

## Author

Generated automatically by Doxygen for MPQC from the source code.
