libwebsockets
Lightweight C library for HTML5 websockets
Toggle main menu visibility
Loading...
Searching...
No Matches
lws-dsh.h
Go to the documentation of this file.
1
/*
2
* libwebsockets - small server side websockets and web server implementation
3
*
4
* Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com>
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to
8
* deal in the Software without restriction, including without limitation the
9
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
* sell copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in
14
* all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
* IN THE SOFTWARE.
23
*/
24
25
/*
26
* lws_dsh (Disordered Shared Heap) is an opaque abstraction supporting a single
27
* linear buffer (overallocated at end of the lws_dsh_t) which may contain
28
* multiple kinds of packets that are retired out of order, and tracked by kind.
29
*
30
* Each kind of packet has an lws_dll2 list of its kind of packets and acts as
31
* a FIFO; packets of a particular type are always retired in order. But there
32
* is no requirement about the order types are retired matching the original
33
* order they arrived.
34
*
35
* Gaps are tracked as just another kind of "packet" list.
36
*
37
* "allocations" (including gaps) are prepended by an lws_dsh_object_t.
38
*
39
* dsh may themselves be on an lws_dll2_owner list, and under memory pressure
40
* allocate into other buffers on the list.
41
*
42
* All management structures exist inside the allocated buffer.
43
*/
44
45
enum
{
46
LWS_DSHFLAG_ENABLE_COALESCE
= (1u << 24),
47
LWS_DSHFLAG_ENABLE_SPLIT
= (1u << 25),
48
};
49
71
LWS_VISIBLE
LWS_EXTERN
struct
lws_dsh *
72
lws_dsh_create
(
lws_dll2_owner_t
*owner,
size_t
buffer_size,
int
count_kinds);
73
74
LWS_VISIBLE
LWS_EXTERN
void
75
lws_dsh_empty
(
struct
lws_dsh *dsh);
76
91
LWS_VISIBLE
LWS_EXTERN
void
92
lws_dsh_destroy
(
struct
lws_dsh **pdsh);
93
112
LWS_VISIBLE
LWS_EXTERN
int
113
lws_dsh_alloc_tail
(
struct
lws_dsh *dsh,
int
kind,
const
void
*src1,
114
size_t
size1,
const
void
*src2,
size_t
size2);
115
124
LWS_VISIBLE
LWS_EXTERN
void
125
lws_dsh_free
(
void
**obj);
126
136
LWS_VISIBLE
LWS_EXTERN
void
137
lws_dsh_consume
(
struct
lws_dsh *dsh,
int
kind,
size_t
len);
138
139
LWS_VISIBLE
LWS_EXTERN
size_t
140
lws_dsh_get_size
(
struct
lws_dsh *dsh,
int
kind);
141
157
LWS_VISIBLE
LWS_EXTERN
int
158
lws_dsh_get_head
(
struct
lws_dsh *dsh,
int
kind,
void
**obj,
size_t
*size);
159
168
LWS_VISIBLE
LWS_EXTERN
void
169
lws_dsh_describe
(
struct
lws_dsh *dsh,
const
char
*desc);
lws_dll2_owner_t
struct lws_dll2_owner lws_dll2_owner_t
LWS_EXTERN
#define LWS_EXTERN
Definition
libwebsockets.h:296
LWS_VISIBLE
#define LWS_VISIBLE
Definition
libwebsockets.h:291
lws_dsh_free
LWS_VISIBLE LWS_EXTERN void lws_dsh_free(void **obj)
LWS_DSHFLAG_ENABLE_SPLIT
@ LWS_DSHFLAG_ENABLE_SPLIT
Definition
lws-dsh.h:47
LWS_DSHFLAG_ENABLE_COALESCE
@ LWS_DSHFLAG_ENABLE_COALESCE
Definition
lws-dsh.h:46
lws_dsh_get_head
LWS_VISIBLE LWS_EXTERN int lws_dsh_get_head(struct lws_dsh *dsh, int kind, void **obj, size_t *size)
lws_dsh_empty
LWS_VISIBLE LWS_EXTERN void lws_dsh_empty(struct lws_dsh *dsh)
lws_dsh_get_size
LWS_VISIBLE LWS_EXTERN size_t lws_dsh_get_size(struct lws_dsh *dsh, int kind)
lws_dsh_create
LWS_VISIBLE LWS_EXTERN struct lws_dsh * lws_dsh_create(lws_dll2_owner_t *owner, size_t buffer_size, int count_kinds)
lws_dsh_alloc_tail
LWS_VISIBLE LWS_EXTERN int lws_dsh_alloc_tail(struct lws_dsh *dsh, int kind, const void *src1, size_t size1, const void *src2, size_t size2)
lws_dsh_destroy
LWS_VISIBLE LWS_EXTERN void lws_dsh_destroy(struct lws_dsh **pdsh)
lws_dsh_consume
LWS_VISIBLE LWS_EXTERN void lws_dsh_consume(struct lws_dsh *dsh, int kind, size_t len)
lws_dsh_describe
LWS_VISIBLE LWS_EXTERN void lws_dsh_describe(struct lws_dsh *dsh, const char *desc)
include
libwebsockets
lws-dsh.h
Generated on
for libwebsockets by
1.18.0