/src/tarantool/src/box/xstream.h
Line | Count | Source |
1 | | #ifndef TARANTOOL_XSTREAM_H_INCLUDED |
2 | | #define TARANTOOL_XSTREAM_H_INCLUDED |
3 | | |
4 | | /* |
5 | | * Copyright 2010-2016, Tarantool AUTHORS, please see AUTHORS file. |
6 | | * |
7 | | * Redistribution and use in source and binary forms, with or |
8 | | * without modification, are permitted provided that the following |
9 | | * conditions are met: |
10 | | * |
11 | | * 1. Redistributions of source code must retain the above |
12 | | * copyright notice, this list of conditions and the |
13 | | * following disclaimer. |
14 | | * |
15 | | * 2. Redistributions in binary form must reproduce the above |
16 | | * copyright notice, this list of conditions and the following |
17 | | * disclaimer in the documentation and/or other materials |
18 | | * provided with the distribution. |
19 | | * |
20 | | * THIS SOFTWARE IS PROVIDED BY AUTHORS ``AS IS'' AND |
21 | | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
22 | | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
23 | | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
24 | | * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
25 | | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
26 | | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
27 | | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
28 | | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
29 | | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
30 | | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
31 | | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
32 | | * SUCH DAMAGE. |
33 | | */ |
34 | | |
35 | | #include "diag.h" |
36 | | |
37 | | #if defined(__cplusplus) |
38 | | extern "C" { |
39 | | #endif /* defined(__cplusplus) */ |
40 | | |
41 | | struct xrow_header; |
42 | | struct xstream; |
43 | | |
44 | | /** |
45 | | * A type for a callback invoked by recovery after some batch of rows is |
46 | | * processed. Is used mostly to unblock the event loop every now and then. |
47 | | */ |
48 | | typedef void (*xstream_yield_f)(struct xstream *); |
49 | | |
50 | | typedef void (*xstream_write_f)(struct xstream *, struct xrow_header *); |
51 | | |
52 | | struct xstream { |
53 | | xstream_write_f write; |
54 | | xstream_yield_f yield; |
55 | | uint64_t row_count; |
56 | | }; |
57 | | |
58 | | static inline void |
59 | | xstream_create(struct xstream *xstream, xstream_write_f write, |
60 | | xstream_yield_f yield) |
61 | 0 | { |
62 | 0 | xstream->write = write; |
63 | 0 | xstream->yield = yield; |
64 | 0 | xstream->row_count = 0; |
65 | 0 | } Unexecuted instantiation: box.cc:xstream_create(xstream*, void (*)(xstream*, xrow_header*), void (*)(xstream*)) Unexecuted instantiation: recovery.cc:xstream_create(xstream*, void (*)(xstream*, xrow_header*), void (*)(xstream*)) Unexecuted instantiation: xstream.cc:xstream_create(xstream*, void (*)(xstream*, xrow_header*), void (*)(xstream*)) Unexecuted instantiation: relay.cc:xstream_create(xstream*, void (*)(xstream*, xrow_header*), void (*)(xstream*)) Unexecuted instantiation: memtx_engine.cc:xstream_create(xstream*, void (*)(xstream*, xrow_header*), void (*)(xstream*)) Unexecuted instantiation: vinyl.c:xstream_create |
66 | | |
67 | | static inline void |
68 | | xstream_yield(struct xstream *stream) |
69 | 0 | { |
70 | 0 | stream->yield(stream); |
71 | 0 | } Unexecuted instantiation: box.cc:xstream_yield(xstream*) Unexecuted instantiation: recovery.cc:xstream_yield(xstream*) Unexecuted instantiation: xstream.cc:xstream_yield(xstream*) Unexecuted instantiation: relay.cc:xstream_yield(xstream*) Unexecuted instantiation: memtx_engine.cc:xstream_yield(xstream*) Unexecuted instantiation: vinyl.c:xstream_yield |
72 | | |
73 | | static inline void |
74 | | xstream_reset(struct xstream *stream) |
75 | 0 | { |
76 | 0 | stream->row_count = 0; |
77 | 0 | xstream_yield(stream); |
78 | 0 | } Unexecuted instantiation: box.cc:xstream_reset(xstream*) Unexecuted instantiation: recovery.cc:xstream_reset(xstream*) Unexecuted instantiation: xstream.cc:xstream_reset(xstream*) Unexecuted instantiation: relay.cc:xstream_reset(xstream*) Unexecuted instantiation: memtx_engine.cc:xstream_reset(xstream*) Unexecuted instantiation: vinyl.c:xstream_reset |
79 | | |
80 | | int |
81 | | xstream_write(struct xstream *stream, struct xrow_header *row); |
82 | | |
83 | | #if defined(__cplusplus) |
84 | | } /* extern C */ |
85 | | |
86 | | static inline void |
87 | | xstream_write_xc(struct xstream *stream, struct xrow_header *row) |
88 | 0 | { |
89 | 0 | if (xstream_write(stream, row) != 0) |
90 | 0 | diag_raise(); |
91 | 0 | } Unexecuted instantiation: box.cc:xstream_write_xc(xstream*, xrow_header*) Unexecuted instantiation: recovery.cc:xstream_write_xc(xstream*, xrow_header*) Unexecuted instantiation: xstream.cc:xstream_write_xc(xstream*, xrow_header*) Unexecuted instantiation: relay.cc:xstream_write_xc(xstream*, xrow_header*) Unexecuted instantiation: memtx_engine.cc:xstream_write_xc(xstream*, xrow_header*) |
92 | | |
93 | | #endif /* defined(__cplusplus) */ |
94 | | |
95 | | #endif /* TARANTOOL_XSTREAM_H_INCLUDED */ |