File: cross_process_lock.h

package info (click to toggle)
aws-crt-python 0.20.4%2Bdfsg-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 72,656 kB
  • sloc: ansic: 381,805; python: 23,008; makefile: 6,251; sh: 4,536; cpp: 699; ruby: 208; java: 77; perl: 73; javascript: 46; xml: 11
file content (35 lines) | stat: -rw-r--r-- 1,252 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef AWS_COMMON_CROSS_PROCESS_LOCK_H
#define AWS_COMMON_CROSS_PROCESS_LOCK_H
/**
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */
#include <aws/common/byte_buf.h>
#include <aws/common/common.h>

struct aws_cross_process_lock;
AWS_EXTERN_C_BEGIN

/**
 * Attempts to acquire a system-wide (not per process or per user) lock scoped by instance_nonce.
 * For any given unique nonce, a lock will be returned by the first caller. Subsequent calls will
 * return NULL and raise AWS_ERROR_MUTEX_CALLER_NOT_OWNER
 * until the either the process owning the lock exits or the program owning the lock
 * calls aws_cross_process_lock_release() explicitly.
 *
 * If the process exits before the lock is released, the kernel will unlock it for the next consumer.
 */
AWS_COMMON_API
struct aws_cross_process_lock *aws_cross_process_lock_try_acquire(
    struct aws_allocator *allocator,
    struct aws_byte_cursor instance_nonce);

/**
 * Releases the lock so the next caller (may be another process) can get an instance of the lock.
 */
AWS_COMMON_API
void aws_cross_process_lock_release(struct aws_cross_process_lock *instance_lock);

AWS_EXTERN_C_END

#endif /* AWS_COMMON_CROSS_PROCESS_LOCK_H */