File: s3_buffer_pool.c

package info (click to toggle)
aws-crt-python 0.28.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,428 kB
  • sloc: ansic: 437,955; python: 27,657; makefile: 5,855; sh: 4,289; ruby: 208; java: 82; perl: 73; cpp: 25; xml: 11
file content (76 lines) | stat: -rw-r--r-- 2,247 bytes parent folder | download
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */

#include "aws/s3/s3_buffer_pool.h"
#include "aws/s3/private/s3_default_buffer_pool.h"

AWS_FUTURE_T_POINTER_WITH_RELEASE_IMPLEMENTATION(
    aws_future_s3_buffer_ticket,
    struct aws_s3_buffer_ticket,
    aws_s3_buffer_ticket_release)

struct aws_s3_buffer_pool *aws_s3_buffer_pool_acquire(struct aws_s3_buffer_pool *buffer_pool) {
    if (buffer_pool != NULL) {
        if (buffer_pool->vtable->acquire) {
            buffer_pool->vtable->acquire(buffer_pool);
        } else {
            aws_ref_count_acquire(&buffer_pool->ref_count);
        }
    }
    return buffer_pool;
}

struct aws_s3_buffer_pool *aws_s3_buffer_pool_release(struct aws_s3_buffer_pool *buffer_pool) {
    if (buffer_pool != NULL) {
        if (buffer_pool->vtable->release) {
            buffer_pool->vtable->release(buffer_pool);
        } else {
            aws_ref_count_release(&buffer_pool->ref_count);
        }
    }
    return NULL;
}

struct aws_future_s3_buffer_ticket *aws_s3_buffer_pool_reserve(
    struct aws_s3_buffer_pool *buffer_pool,
    struct aws_s3_buffer_pool_reserve_meta meta) {
    AWS_PRECONDITION(buffer_pool);

    return buffer_pool->vtable->reserve(buffer_pool, meta);
}

void aws_s3_buffer_pool_trim(struct aws_s3_buffer_pool *buffer_pool) {
    AWS_PRECONDITION(buffer_pool);

    buffer_pool->vtable->trim(buffer_pool);
}

struct aws_s3_buffer_ticket *aws_s3_buffer_ticket_acquire(struct aws_s3_buffer_ticket *ticket) {
    if (ticket != NULL) {
        if (ticket->vtable->acquire) {
            ticket->vtable->acquire(ticket);
        } else {
            aws_ref_count_acquire(&ticket->ref_count);
        }
    }
    return ticket;
}

struct aws_s3_buffer_ticket *aws_s3_buffer_ticket_release(struct aws_s3_buffer_ticket *ticket) {
    if (ticket != NULL) {
        if (ticket->vtable->release) {
            ticket->vtable->release(ticket);
        } else {
            aws_ref_count_release(&ticket->ref_count);
        }
    }
    return NULL;
}

struct aws_byte_buf aws_s3_buffer_ticket_claim(struct aws_s3_buffer_ticket *ticket) {
    AWS_PRECONDITION(ticket);

    return ticket->vtable->claim(ticket);
}