Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../usr/include/fstrm
File: iothr.h
/*
[0] Fix | Delete
* Copyright (c) 2014 by Farsight Security, Inc.
[1] Fix | Delete
*
[2] Fix | Delete
* Permission is hereby granted, free of charge, to any person obtaining
[3] Fix | Delete
* a copy of this software and associated documentation files (the
[4] Fix | Delete
* "Software"), to deal in the Software without restriction, including
[5] Fix | Delete
* without limitation the rights to use, copy, modify, merge, publish,
[6] Fix | Delete
* distribute, sublicense, and/or sell copies of the Software, and to
[7] Fix | Delete
* permit persons to whom the Software is furnished to do so, subject to
[8] Fix | Delete
* the following conditions:
[9] Fix | Delete
*
[10] Fix | Delete
* The above copyright notice and this permission notice shall be included
[11] Fix | Delete
* in all copies or substantial portions of the Software.
[12] Fix | Delete
*
[13] Fix | Delete
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
[14] Fix | Delete
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
[15] Fix | Delete
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
[16] Fix | Delete
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
[17] Fix | Delete
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
[18] Fix | Delete
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
[19] Fix | Delete
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[20] Fix | Delete
*
[21] Fix | Delete
*/
[22] Fix | Delete
[23] Fix | Delete
#ifndef FSTRM_IOTHR_H
[24] Fix | Delete
#define FSTRM_IOTHR_H
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* \defgroup fstrm_iothr fstrm_iothr
[28] Fix | Delete
*
[29] Fix | Delete
* The `fstrm_iothr` interface creates a background I/O thread which writes
[30] Fix | Delete
* Frame Streams encapsulated data frames into an output stream specified by an
[31] Fix | Delete
* \ref fstrm_writer object. It exposes non-blocking input queues that can be
[32] Fix | Delete
* used by worker threads to asynchronously write data frames to the output
[33] Fix | Delete
* stream. A deferred deallocation callback is invoked after the I/O thread has
[34] Fix | Delete
* disposed of a queued data frame.
[35] Fix | Delete
*
[36] Fix | Delete
* In order to create an `fstrm_iothr` object, the caller must first configure
[37] Fix | Delete
* and instantiate an `fstrm_writer` object and pass this instance to the
[38] Fix | Delete
* fstrm_iothr_init() function. The `fstrm_iothr` object then takes ownership of
[39] Fix | Delete
* the `fstrm_writer` object. It is responsible for serializing writes and will
[40] Fix | Delete
* take care of destroying the captive `fstrm_writer` object at the same time
[41] Fix | Delete
* the `fstrm_iothr` object is destroyed. The caller should not perform any
[42] Fix | Delete
* operations on the captive `fstrm_writer` object after it has been passed to
[43] Fix | Delete
* `fstrm_iothr_init()`.
[44] Fix | Delete
*
[45] Fix | Delete
* Parameters used to configure the I/O thread are passed through an
[46] Fix | Delete
* `fstrm_iothr_options` object. These options have to be specified in advance
[47] Fix | Delete
* and are mostly performance knobs which have reasonable defaults.
[48] Fix | Delete
*
[49] Fix | Delete
* Once the `fstrm_iothr` object has been created, handles to the input queues
[50] Fix | Delete
* used to submit data frames can be obtained by calling
[51] Fix | Delete
* `fstrm_iothr_get_input_queue()`. This function can be called up to
[52] Fix | Delete
* **num_input_queues** times, and can be safely called concurrently. For
[53] Fix | Delete
* instance, in an application with a fixed number of worker threads, an input
[54] Fix | Delete
* queue can be dedicated to each worker thread by setting the
[55] Fix | Delete
* **num_input_queues** option to the number of worker threads, and then calling
[56] Fix | Delete
* `fstrm_iothr_get_input_queue()` from each worker thread's startup function to
[57] Fix | Delete
* obtain a per-thread input queue.
[58] Fix | Delete
*
[59] Fix | Delete
* @{
[60] Fix | Delete
*/
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Initialize an `fstrm_iothr_options` object. This is needed to pass
[64] Fix | Delete
* configuration parameters to fstrm_iothr_init().
[65] Fix | Delete
*
[66] Fix | Delete
* \return
[67] Fix | Delete
* `fstrm_iothr_options` object.
[68] Fix | Delete
*/
[69] Fix | Delete
struct fstrm_iothr_options *
[70] Fix | Delete
fstrm_iothr_options_init(void);
[71] Fix | Delete
[72] Fix | Delete
/**
[73] Fix | Delete
* Destroy an `fstrm_iothr_options` object.
[74] Fix | Delete
*
[75] Fix | Delete
* \param opt
[76] Fix | Delete
* Pointer to `fstrm_iothr_options` object.
[77] Fix | Delete
*/
[78] Fix | Delete
void
[79] Fix | Delete
fstrm_iothr_options_destroy(struct fstrm_iothr_options **opt);
[80] Fix | Delete
[81] Fix | Delete
/**
[82] Fix | Delete
* Set the `buffer_hint` parameter. This is the threshold number of bytes to
[83] Fix | Delete
* accumulate in the output buffer before forcing a buffer flush.
[84] Fix | Delete
*
[85] Fix | Delete
* \param opt
[86] Fix | Delete
* `fstrm_iothr_options` object.
[87] Fix | Delete
* \param buffer_hint
[88] Fix | Delete
* New `buffer_hint` value.
[89] Fix | Delete
*
[90] Fix | Delete
* \retval #fstrm_res_success
[91] Fix | Delete
* \retval #fstrm_res_failure
[92] Fix | Delete
*/
[93] Fix | Delete
fstrm_res
[94] Fix | Delete
fstrm_iothr_options_set_buffer_hint(
[95] Fix | Delete
struct fstrm_iothr_options *opt,
[96] Fix | Delete
unsigned buffer_hint);
[97] Fix | Delete
[98] Fix | Delete
/** Minimum `buffer_hint` value. */
[99] Fix | Delete
#define FSTRM_IOTHR_BUFFER_HINT_MIN 1024
[100] Fix | Delete
[101] Fix | Delete
/** Default `buffer_hint` value. */
[102] Fix | Delete
#define FSTRM_IOTHR_BUFFER_HINT_DEFAULT 8192
[103] Fix | Delete
[104] Fix | Delete
/** Maximum `buffer_hint` value. */
[105] Fix | Delete
#define FSTRM_IOTHR_BUFFER_HINT_MAX 65536
[106] Fix | Delete
[107] Fix | Delete
/**
[108] Fix | Delete
* Set the `flush_timeout` parameter. This is the number of seconds to allow
[109] Fix | Delete
* unflushed data to remain in the output buffer.
[110] Fix | Delete
*
[111] Fix | Delete
* \param opt
[112] Fix | Delete
* `fstrm_iothr_options` object.
[113] Fix | Delete
* \param flush_timeout
[114] Fix | Delete
* New `flush_timeout` value.
[115] Fix | Delete
*
[116] Fix | Delete
* \retval #fstrm_res_success
[117] Fix | Delete
* \retval #fstrm_res_failure
[118] Fix | Delete
*/
[119] Fix | Delete
fstrm_res
[120] Fix | Delete
fstrm_iothr_options_set_flush_timeout(
[121] Fix | Delete
struct fstrm_iothr_options *opt,
[122] Fix | Delete
unsigned flush_timeout);
[123] Fix | Delete
[124] Fix | Delete
/** Minimum `flush_timeout` value. */
[125] Fix | Delete
#define FSTRM_IOTHR_FLUSH_TIMEOUT_MIN 1
[126] Fix | Delete
[127] Fix | Delete
/** Default `flush_timeout` value. */
[128] Fix | Delete
#define FSTRM_IOTHR_FLUSH_TIMEOUT_DEFAULT 1
[129] Fix | Delete
[130] Fix | Delete
/** Maximum `flush_timeout` value. */
[131] Fix | Delete
#define FSTRM_IOTHR_FLUSH_TIMEOUT_MAX 600
[132] Fix | Delete
[133] Fix | Delete
/**
[134] Fix | Delete
* Set the `input_queue_size` parameter. This is the number of queue entries to
[135] Fix | Delete
* allocate per each input queue. This option controls the number of outstanding
[136] Fix | Delete
* data frames per input queue that can be outstanding for deferred processing
[137] Fix | Delete
* by the `fstrm_iothr` object and thus affects performance and memory usage.
[138] Fix | Delete
*
[139] Fix | Delete
* This parameter must be a power-of-2.
[140] Fix | Delete
*
[141] Fix | Delete
* \param opt
[142] Fix | Delete
* `fstrm_iothr_options` object.
[143] Fix | Delete
* \param input_queue_size
[144] Fix | Delete
* New `input_queue_size` value.
[145] Fix | Delete
*
[146] Fix | Delete
* \retval #fstrm_res_success
[147] Fix | Delete
* \retval #fstrm_res_failure
[148] Fix | Delete
*/
[149] Fix | Delete
fstrm_res
[150] Fix | Delete
fstrm_iothr_options_set_input_queue_size(
[151] Fix | Delete
struct fstrm_iothr_options *opt,
[152] Fix | Delete
unsigned input_queue_size);
[153] Fix | Delete
[154] Fix | Delete
/** Minimum `input_queue_size` value. */
[155] Fix | Delete
#define FSTRM_IOTHR_INPUT_QUEUE_SIZE_MIN 2
[156] Fix | Delete
[157] Fix | Delete
/** Default `input_queue_size` value. */
[158] Fix | Delete
#define FSTRM_IOTHR_INPUT_QUEUE_SIZE_DEFAULT 512
[159] Fix | Delete
[160] Fix | Delete
/** Maximum `input_queue_size` value. */
[161] Fix | Delete
#define FSTRM_IOTHR_INPUT_QUEUE_SIZE_MAX 16384
[162] Fix | Delete
[163] Fix | Delete
/**
[164] Fix | Delete
* Set the `num_input_queues` parameter. This is the number of input queues to
[165] Fix | Delete
* create and must match the number of times that fstrm_iothr_get_input_queue()
[166] Fix | Delete
* is called on the corresponding `fstrm_iothr` object.
[167] Fix | Delete
*
[168] Fix | Delete
* \param opt
[169] Fix | Delete
* `fstrm_iothr_options` object.
[170] Fix | Delete
* \param num_input_queues
[171] Fix | Delete
* New `num_input_queues` value.
[172] Fix | Delete
*
[173] Fix | Delete
* \retval #fstrm_res_success
[174] Fix | Delete
* \retval #fstrm_res_failure
[175] Fix | Delete
*/
[176] Fix | Delete
fstrm_res
[177] Fix | Delete
fstrm_iothr_options_set_num_input_queues(
[178] Fix | Delete
struct fstrm_iothr_options *opt,
[179] Fix | Delete
unsigned num_input_queues);
[180] Fix | Delete
[181] Fix | Delete
/** Minimum `num_input_queues` value. */
[182] Fix | Delete
#define FSTRM_IOTHR_NUM_INPUT_QUEUES_MIN 1
[183] Fix | Delete
[184] Fix | Delete
/** Default `num_input_queues` value. */
[185] Fix | Delete
#define FSTRM_IOTHR_NUM_INPUT_QUEUES_DEFAULT 1
[186] Fix | Delete
[187] Fix | Delete
/**
[188] Fix | Delete
* Set the `output_queue_size` parameter. This is the number of queue entries to
[189] Fix | Delete
* allocate for the output queue. This option controls the maximum number of
[190] Fix | Delete
* data frames that can be accumulated in the output queue before a buffer flush
[191] Fix | Delete
* must occur and thus affects performance and memory usage.
[192] Fix | Delete
*
[193] Fix | Delete
* \param opt
[194] Fix | Delete
* `fstrm_iothr_options` object.
[195] Fix | Delete
* \param output_queue_size
[196] Fix | Delete
* New `output_queue_size` value.
[197] Fix | Delete
*
[198] Fix | Delete
* \retval #fstrm_res_success
[199] Fix | Delete
* \retval #fstrm_res_failure
[200] Fix | Delete
*/
[201] Fix | Delete
fstrm_res
[202] Fix | Delete
fstrm_iothr_options_set_output_queue_size(
[203] Fix | Delete
struct fstrm_iothr_options *opt,
[204] Fix | Delete
unsigned output_queue_size);
[205] Fix | Delete
[206] Fix | Delete
/** Minimum `output_queue_size` value. */
[207] Fix | Delete
#define FSTRM_IOTHR_OUTPUT_QUEUE_SIZE_MIN 2
[208] Fix | Delete
[209] Fix | Delete
/** Default `output_queue_size` value. */
[210] Fix | Delete
#define FSTRM_IOTHR_OUTPUT_QUEUE_SIZE_DEFAULT 64
[211] Fix | Delete
[212] Fix | Delete
/** Maximum `output_queue_size` value. */
[213] Fix | Delete
#define FSTRM_IOTHR_OUTPUT_QUEUE_SIZE_MAX IOV_MAX
[214] Fix | Delete
[215] Fix | Delete
/**
[216] Fix | Delete
* Queue models.
[217] Fix | Delete
* \see fstrm_iothr_options_set_queue_model()
[218] Fix | Delete
*/
[219] Fix | Delete
typedef enum {
[220] Fix | Delete
/** Single Producer, Single Consumer. */
[221] Fix | Delete
FSTRM_IOTHR_QUEUE_MODEL_SPSC,
[222] Fix | Delete
[223] Fix | Delete
/** Multiple Producer, Single Consumer. */
[224] Fix | Delete
FSTRM_IOTHR_QUEUE_MODEL_MPSC,
[225] Fix | Delete
} fstrm_iothr_queue_model;
[226] Fix | Delete
[227] Fix | Delete
[228] Fix | Delete
/**
[229] Fix | Delete
* Set the `queue_model` parameter. This controls what queueing semantics to use
[230] Fix | Delete
* for `fstrm_iothr_queue` objects. Single Producer queues
[231] Fix | Delete
* (#FSTRM_IOTHR_QUEUE_MODEL_SPSC) may only have a single thread at a time
[232] Fix | Delete
* calling fstrm_iothr_submit() on a given `fstrm_iothr_queue` object, while
[233] Fix | Delete
* Multiple Producer queues (#FSTRM_IOTHR_QUEUE_MODEL_MPSC) may have multiple
[234] Fix | Delete
* threads concurrently calling fstrm_iothr_submit() on a given
[235] Fix | Delete
* `fstrm_iothr_queue` object.
[236] Fix | Delete
*
[237] Fix | Delete
* \param opt
[238] Fix | Delete
* `fstrm_iothr_options` object.
[239] Fix | Delete
* \param queue_model
[240] Fix | Delete
* New `queue_model` value.
[241] Fix | Delete
*
[242] Fix | Delete
* \retval #fstrm_res_success
[243] Fix | Delete
* \retval #fstrm_res_failure
[244] Fix | Delete
*/
[245] Fix | Delete
fstrm_res
[246] Fix | Delete
fstrm_iothr_options_set_queue_model(
[247] Fix | Delete
struct fstrm_iothr_options *opt,
[248] Fix | Delete
fstrm_iothr_queue_model queue_model);
[249] Fix | Delete
[250] Fix | Delete
/** Default `queue_model` value. */
[251] Fix | Delete
#define FSTRM_IOTHR_QUEUE_MODEL_DEFAULT FSTRM_IOTHR_QUEUE_MODEL_SPSC
[252] Fix | Delete
[253] Fix | Delete
/**
[254] Fix | Delete
* Set the `queue_notify_threshold` parameter. This controls the number of
[255] Fix | Delete
* outstanding queue entries to allow on an input queue before waking the I/O
[256] Fix | Delete
* thread, which will cause the outstanding queue entries to begin draining.
[257] Fix | Delete
*
[258] Fix | Delete
* \param opt
[259] Fix | Delete
* `fstrm_iothr_options` object.
[260] Fix | Delete
* \param queue_notify_threshold
[261] Fix | Delete
* New `queue_notify_threshold` value.
[262] Fix | Delete
*
[263] Fix | Delete
* \retval #fstrm_res_success
[264] Fix | Delete
* \retval #fstrm_res_failure
[265] Fix | Delete
*/
[266] Fix | Delete
fstrm_res
[267] Fix | Delete
fstrm_iothr_options_set_queue_notify_threshold(
[268] Fix | Delete
struct fstrm_iothr_options *opt,
[269] Fix | Delete
unsigned queue_notify_threshold);
[270] Fix | Delete
[271] Fix | Delete
/** Minimum `queue_notify_threshold` value. */
[272] Fix | Delete
#define FSTRM_IOTHR_QUEUE_NOTIFY_THRESHOLD_MIN 1
[273] Fix | Delete
[274] Fix | Delete
/** Default `queue_notify_threshold` value. */
[275] Fix | Delete
#define FSTRM_IOTHR_QUEUE_NOTIFY_THRESHOLD_DEFAULT 32
[276] Fix | Delete
[277] Fix | Delete
/**
[278] Fix | Delete
* Set the `reopen_interval` parameter. This controls the number of seconds to
[279] Fix | Delete
* wait between attempts to reopen a closed `fstrm_writer` output stream.
[280] Fix | Delete
*
[281] Fix | Delete
* \param opt
[282] Fix | Delete
* `fstrm_iothr_options` object.
[283] Fix | Delete
* \param reopen_interval
[284] Fix | Delete
* New `queue_notify_threshold` value.
[285] Fix | Delete
*
[286] Fix | Delete
* \retval #fstrm_res_success
[287] Fix | Delete
* \retval #fstrm_res_failure
[288] Fix | Delete
*/
[289] Fix | Delete
fstrm_res
[290] Fix | Delete
fstrm_iothr_options_set_reopen_interval(
[291] Fix | Delete
struct fstrm_iothr_options *opt,
[292] Fix | Delete
unsigned reopen_interval);
[293] Fix | Delete
[294] Fix | Delete
/** Minimum `reopen_interval` value. */
[295] Fix | Delete
#define FSTRM_IOTHR_REOPEN_INTERVAL_MIN 1
[296] Fix | Delete
[297] Fix | Delete
/** Default `reopen_interval` value. */
[298] Fix | Delete
#define FSTRM_IOTHR_REOPEN_INTERVAL_DEFAULT 5
[299] Fix | Delete
[300] Fix | Delete
/** Maximum `reopen_interval` value. */
[301] Fix | Delete
#define FSTRM_IOTHR_REOPEN_INTERVAL_MAX 600
[302] Fix | Delete
[303] Fix | Delete
/**
[304] Fix | Delete
* Initialize an `fstrm_iothr` object. This creates a background I/O thread
[305] Fix | Delete
* which asynchronously writes data frames submitted by other threads which call
[306] Fix | Delete
* fstrm_iothr_submit().
[307] Fix | Delete
*
[308] Fix | Delete
* \param opt
[309] Fix | Delete
* `fstrm_iothr_options` object. May be NULL, in which case default values
[310] Fix | Delete
* will be used.
[311] Fix | Delete
*
[312] Fix | Delete
* \param writer
[313] Fix | Delete
* Pointer to `fstrm_writer` object. Must be non-NULL.
[314] Fix | Delete
*
[315] Fix | Delete
* \return
[316] Fix | Delete
* `fstrm_iothr` object.
[317] Fix | Delete
* \retval
[318] Fix | Delete
* NULL on failure.
[319] Fix | Delete
*/
[320] Fix | Delete
struct fstrm_iothr *
[321] Fix | Delete
fstrm_iothr_init(
[322] Fix | Delete
const struct fstrm_iothr_options *opt,
[323] Fix | Delete
struct fstrm_writer **writer);
[324] Fix | Delete
[325] Fix | Delete
/**
[326] Fix | Delete
* Destroy an `fstrm_iothr` object. This signals the background I/O thread to
[327] Fix | Delete
* flush or discard any queued data frames and deallocates any resources used
[328] Fix | Delete
* internally. This function blocks until the I/O thread has terminated.
[329] Fix | Delete
*
[330] Fix | Delete
* \param iothr
[331] Fix | Delete
* Pointer to `fstrm_iothr` object.
[332] Fix | Delete
*/
[333] Fix | Delete
void
[334] Fix | Delete
fstrm_iothr_destroy(struct fstrm_iothr **iothr);
[335] Fix | Delete
[336] Fix | Delete
/**
[337] Fix | Delete
* Obtain an `fstrm_iothr_queue` object for submitting data frames to the
[338] Fix | Delete
* `fstrm_iothr` object. `fstrm_iothr_queue` objects are child objects of their
[339] Fix | Delete
* parent `fstrm_iothr` object and will be destroyed when fstrm_iothr_destroy()
[340] Fix | Delete
* is called on the parent `fstrm_iothr` object.
[341] Fix | Delete
*
[342] Fix | Delete
* This function is thread-safe and may be called simultaneously from any
[343] Fix | Delete
* thread. For example, in a program which employs a fixed number of worker
[344] Fix | Delete
* threads to handle requests, fstrm_iothr_get_input_queue() may be called from
[345] Fix | Delete
* a thread startup routine without synchronization.
[346] Fix | Delete
*
[347] Fix | Delete
* `fstrm_iothr` objects allocate a fixed total number of `fstrm_iothr_queue`
[348] Fix | Delete
* objects during the call to fstrm_iothr_init(). To adjust this parameter, use
[349] Fix | Delete
* fstrm_iothr_options_set_num_input_queues().
[350] Fix | Delete
*
[351] Fix | Delete
* This function will fail if it is called more than **num_input_queues** times.
[352] Fix | Delete
* By default, only one input queue is initialized per `fstrm_iothr` object.
[353] Fix | Delete
*
[354] Fix | Delete
* For optimum performance in a threaded program, each worker thread submitting
[355] Fix | Delete
* data frames should have a dedicated `fstrm_iothr_queue` object. This allows
[356] Fix | Delete
* each worker thread to have its own queue which is processed independently by
[357] Fix | Delete
* the I/O thread. If the queue model for the `fstrm_iothr` object is set to
[358] Fix | Delete
* #FSTRM_IOTHR_QUEUE_MODEL_SPSC, this results in contention-free access to the
[359] Fix | Delete
* input queue.
[360] Fix | Delete
*
[361] Fix | Delete
* \param iothr
[362] Fix | Delete
* `fstrm_iothr` object.
[363] Fix | Delete
*
[364] Fix | Delete
* \return
[365] Fix | Delete
* `fstrm_iothr_queue` object.
[366] Fix | Delete
* \retval
[367] Fix | Delete
* NULL on failure.
[368] Fix | Delete
*/
[369] Fix | Delete
struct fstrm_iothr_queue *
[370] Fix | Delete
fstrm_iothr_get_input_queue(struct fstrm_iothr *iothr);
[371] Fix | Delete
[372] Fix | Delete
/**
[373] Fix | Delete
* Obtain an `fstrm_iothr_queue` object for submitting data frames to the
[374] Fix | Delete
* `fstrm_iothr` object. This function is like fstrm_iothr_get_input_queue()
[375] Fix | Delete
* except it indexes into the `fstrm_iothr_queue`'s array of input queues.
[376] Fix | Delete
*
[377] Fix | Delete
* \param iothr
[378] Fix | Delete
* `fstrm_iothr` object.
[379] Fix | Delete
* \param idx
[380] Fix | Delete
* Index of the `fstrm_iothr_queue` object to retrieve. This value is
[381] Fix | Delete
* limited by the **num_input_queues** option.
[382] Fix | Delete
*
[383] Fix | Delete
* \return
[384] Fix | Delete
* `fstrm_iothr_queue` object.
[385] Fix | Delete
* \retval
[386] Fix | Delete
* NULL on failure.
[387] Fix | Delete
*/
[388] Fix | Delete
struct fstrm_iothr_queue *
[389] Fix | Delete
fstrm_iothr_get_input_queue_idx(struct fstrm_iothr *iothr, size_t idx);
[390] Fix | Delete
[391] Fix | Delete
/**
[392] Fix | Delete
* Submit a data frame to the background I/O thread. If successfully queued and
[393] Fix | Delete
* the I/O thread has an active output stream opened, the data frame will be
[394] Fix | Delete
* asynchronously written to the output stream.
[395] Fix | Delete
*
[396] Fix | Delete
* When this function returns #fstrm_res_success, responsibility for
[397] Fix | Delete
* deallocating the data frame specified by the `data` parameter passes to the
[398] Fix | Delete
* `fstrm` library. The caller **MUST** ensure that the `data` object remains
[399] Fix | Delete
* valid after fstrm_iothr_submit() returns. The callback function specified by
[400] Fix | Delete
* the `free_func` parameter will be invoked once the data frame is no longer
[401] Fix | Delete
* needed by the `fstrm` library. For example, if the data frame is dynamically
[402] Fix | Delete
* allocated, the data frame may be deallocated in the callback function.
[403] Fix | Delete
*
[404] Fix | Delete
* Note that if this function returns #fstrm_res_failure, the responsibility for
[405] Fix | Delete
* deallocating the data frame remains with the caller.
[406] Fix | Delete
*
[407] Fix | Delete
* As a convenience, if `data` is allocated with the system's `malloc()`,
[408] Fix | Delete
* `fstrm_free_wrapper` may be provided as the `free_func` parameter with the
[409] Fix | Delete
* `free_data` parameter set to `NULL`. This will cause the system's `free()` to
[410] Fix | Delete
* be invoked to deallocate `data`.
[411] Fix | Delete
*
[412] Fix | Delete
* `free_func` may be NULL, in which case no callback function will be invoked
[413] Fix | Delete
* to dispose of `buf`. This behavior may be useful if `data` is a global,
[414] Fix | Delete
* statically allocated object.
[415] Fix | Delete
*
[416] Fix | Delete
* \param iothr
[417] Fix | Delete
* `fstrm_iothr` object.
[418] Fix | Delete
* \param ioq
[419] Fix | Delete
* `fstrm_iothr_queue` object.
[420] Fix | Delete
* \param data
[421] Fix | Delete
* Data frame bytes.
[422] Fix | Delete
* \param len
[423] Fix | Delete
* Number of bytes in `data`.
[424] Fix | Delete
* \param free_func
[425] Fix | Delete
* Callback function to deallocate the data frame. The `data` and
[426] Fix | Delete
* `free_data` parameters passed to this callback will be the same values
[427] Fix | Delete
* originally supplied in the call to fstrm_iothr_submit().
[428] Fix | Delete
* \param free_data
[429] Fix | Delete
* Parameter to pass to `free_func`.
[430] Fix | Delete
*
[431] Fix | Delete
* \retval #fstrm_res_success
[432] Fix | Delete
* The data frame was successfully queued.
[433] Fix | Delete
* \retval #fstrm_res_again
[434] Fix | Delete
* The queue is full.
[435] Fix | Delete
* \retval #fstrm_res_failure
[436] Fix | Delete
* Permanent failure.
[437] Fix | Delete
*/
[438] Fix | Delete
fstrm_res
[439] Fix | Delete
fstrm_iothr_submit(
[440] Fix | Delete
struct fstrm_iothr *iothr, struct fstrm_iothr_queue *ioq,
[441] Fix | Delete
void *data, size_t len,
[442] Fix | Delete
void (*free_func)(void *buf, void *free_data), void *free_data);
[443] Fix | Delete
[444] Fix | Delete
/**
[445] Fix | Delete
* Wrapper function for the system's `free()`, suitable for use as the
[446] Fix | Delete
* `free_func` callback for fstrm_iothr_submit().
[447] Fix | Delete
*
[448] Fix | Delete
* \param data
[449] Fix | Delete
* Object to call `free()` on.
[450] Fix | Delete
* \param free_data
[451] Fix | Delete
* Unused.
[452] Fix | Delete
*/
[453] Fix | Delete
void
[454] Fix | Delete
fstrm_free_wrapper(void *data, void *free_data);
[455] Fix | Delete
[456] Fix | Delete
/**@}*/
[457] Fix | Delete
[458] Fix | Delete
#endif /* FSTRM_IOTHR_H */
[459] Fix | Delete
[460] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function