---
name: "bson_context_new"
section: "3"
platform: "linux"
package: "libbson-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/bson_context_new"
---

# bson\_context\_new(3)

## SYNOPSIS

```
bson_context_t *
bson_context_new (bson_context_flags_t flags);
```

## PARAMETERS

- •

  **flags**: A *bson\_context\_flags\_t*.

The following **flags** may be used: \* **BSON\_CONTEXT\_NONE** meaning creating ObjectIDs with this context is not a thread-safe operation. \* **BSON\_CONTEXT\_DISABLE\_PID\_CACHE** meaning creating ObjectIDs will also check if the process has changed by calling **getpid()** on every ObjectID generation.

The following flags are deprecated and have no effect:

- •

  **BSON\_CONTEXT\_DISABLE\_HOST\_CACHE**

- •

  **BSON\_CONTEXT\_THREAD\_SAFE**

- •

  **BSON\_CONTEXT\_USE\_TASK\_ID**

## DESCRIPTION

Creates a new *bson\_context\_t*. This is rarely needed as *bson\_context\_get\_default()* serves most use-cases.

## RETURNS

A newly allocated *bson\_context\_t* that should be freed with *bson\_context\_destroy()*.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
