src/core/buffer.h File Reference

Buffer manager interface. More...

#include <misc/result.h>

Go to the source code of this file.

Classes

struct  txc_buffer_circular_s
 A structure to represent a circular buffer. More...
struct  txc_buffer_linear_s

Defines

#define TXC_BUFFER_CIRCULAR_SIZE   1024*(64*2)*64
#define TXC_BUFFER_CIRCULAR_NUM   32
#define TXC_BUFFER_LINEAR_SIZE   1024*256
#define TXC_BUFFER_LINEAR_NUM   32

Typedefs

typedef txc_buffermgr_s txc_buffermgr_t
typedef txc_buffer_circular_s txc_buffer_circular_t
typedef txc_buffer_linear_s txc_buffer_linear_t
typedef txc_buffer_circular_memento_s txc_buffer_circular_memento_t
typedef txc_buffer_linear_memento_s txc_buffer_linear_memento_t

Enumerations

enum  txc_buffer_state_t { TXC_BUFFER_STATE_NON_SPECULATIVE = 0, TXC_BUFFER_STATE_SPECULATIVE = 1 }

Functions

txc_result_t txc_buffermgr_create (txc_buffermgr_t **)
 Creates a buffer manager.
void txc_buffermgr_destroy (txc_buffermgr_t **)
 Destroys a buffer manager.
txc_result_t txc_buffer_circular_create (txc_buffermgr_t *buffermgr, txc_buffer_circular_t **bufferp)
 Creates and initializes a new circular buffer.
void txc_buffer_circular_destroy (txc_buffer_circular_t **bufferp)
 Destroys a circular buffer.
txc_result_t txc_buffer_circular_init (txc_buffer_circular_t *buffer)
 Initializes an existing circular buffer.
txc_result_t txc_buffer_linear_create (txc_buffermgr_t *buffermgr, txc_buffer_linear_t **bufferp)
 Creates and initializes a new linear buffer.
void txc_buffer_linear_destroy (txc_buffer_linear_t **bufferp)
 Destroys a linear buffer.
txc_result_t txc_buffer_linear_init (txc_buffer_linear_t *buffer)
 Initializes an existing linear buffer.
void * txc_buffer_linear_malloc (txc_buffer_linear_t *buffer, unsigned int size)
 Allocates a linear region from a linear buffer.
void txc_buffer_linear_free (txc_buffer_linear_t *buffer, unsigned int size)
 Deallocates a linear region previously allocated from a linear buffer.

Variables

txc_buffermgr_ttxc_g_buffermgr


Detailed Description

Buffer manager interface.

Definition in file buffer.h.


Function Documentation

txc_result_t txc_buffer_circular_create ( txc_buffermgr_t buffermgr,
txc_buffer_circular_t **  bufferp 
)

Creates and initializes a new circular buffer.

Parameters:
[in] buffermgr The buffer manager responsible for the buffer.
[out] bufferp The newly created buffer.
Returns:
Code indicating success or failure (reason) of the operation.

Definition at line 186 of file buffer.c.

References txc_buffermgr_s::pool_buffer_circular, txc_buffer_circular_init(), TXC_INTERNALERROR, txc_pool_object_alloc(), and TXC_R_SUCCESS.

Referenced by txc_koa_create().

void txc_buffer_circular_destroy ( txc_buffer_circular_t **  bufferp  ) 

Destroys a circular buffer.

Parameters:
[in,out] bufferp The buffer to be destroyed.

Definition at line 214 of file buffer.c.

References txc_buffermgr_s::pool_buffer_circular, and txc_pool_object_free().

Referenced by txc_koa_destroy().

txc_result_t txc_buffer_circular_init ( txc_buffer_circular_t buffer  ) 

Initializes an existing circular buffer.

Parameters:
[in] buffer The buffer to be initialized.
Returns:
Code indicating success or failure (reason) of the operation.

Definition at line 166 of file buffer.c.

References txc_buffer_circular_s::primary_head, txc_buffer_circular_s::primary_tail, txc_buffer_circular_s::secondary_head, txc_buffer_circular_s::secondary_tail, txc_buffer_circular_s::state, and TXC_R_SUCCESS.

Referenced by txc_buffer_circular_create().

txc_result_t txc_buffer_linear_create ( txc_buffermgr_t buffermgr,
txc_buffer_linear_t **  bufferp 
)

Creates and initializes a new linear buffer.

Parameters:
[in] buffermgr The buffer manager responsible for the buffer.
[out] bufferp The newly created buffer.
Returns:
Code indicating success or failure (reason) of the operation.

Definition at line 255 of file buffer.c.

References txc_buffermgr_s::pool_buffer_linear, txc_buffer_linear_init(), TXC_INTERNALERROR, txc_pool_object_alloc(), and TXC_R_SUCCESS.

Referenced by txc_txmgr_create().

void txc_buffer_linear_destroy ( txc_buffer_linear_t **  bufferp  ) 

Destroys a linear buffer.

Parameters:
[in,out] bufferp The buffer to be destroyed.

Definition at line 283 of file buffer.c.

References txc_buffermgr_s::pool_buffer_linear, and txc_pool_object_free().

Referenced by txc_txmgr_destroy().

void txc_buffer_linear_free ( txc_buffer_linear_t buffer,
unsigned int  size 
)

Deallocates a linear region previously allocated from a linear buffer.

Deallocation operations must be in the reverse order of the allocation operations.

[in] buffer The buffer from which the region was allocated. [in] size The size of the region to be allocated.

Definition at line 325 of file buffer.c.

References txc_buffer_linear_s::cur_len.

Referenced by x_lseek(), x_read(), x_sendmsg(), and x_write_pipe().

txc_result_t txc_buffer_linear_init ( txc_buffer_linear_t buffer  ) 

Initializes an existing linear buffer.

Parameters:
[in] buffer The buffer to be initialized.
Returns:
Code indicating success or failure (reason) of the operation.

Definition at line 238 of file buffer.c.

References txc_buffer_linear_s::cur_len, txc_buffer_linear_s::state, and TXC_R_SUCCESS.

Referenced by txc_buffer_linear_create().

void* txc_buffer_linear_malloc ( txc_buffer_linear_t buffer,
unsigned int  size 
)

Allocates a linear region from a linear buffer.

Parameters:
[in] buffer The buffer from which the region is allocated.
[in] size The size of the region to be allocated.
Returns:
A pointer to the allocated region or NULL if allocated failed.

Definition at line 300 of file buffer.c.

References txc_buffer_linear_s::buf, txc_buffer_linear_s::cur_len, and txc_buffer_linear_s::size_max.

Referenced by x_close(), x_create(), x_dup(), x_fsync(), x_lseek(), x_open(), x_pipe(), x_pthread_mutex_lock(), x_pthread_mutex_unlock(), x_read(), x_rename(), x_sendmsg(), x_socket(), x_unlink(), and x_write_pipe().

txc_result_t txc_buffermgr_create ( txc_buffermgr_t **  buffermgrp  ) 

Creates a buffer manager.

It preallocates a pool of circular and linear buffers to make allocation fast.

Parameters:
[out] buffermgrp The created buffer manager.
Returns:
Code indicating success or failure (reason) of the operation.

Definition at line 73 of file buffer.c.

References FREE, MALLOC, TXC_BUFFER_CIRCULAR_NUM, TXC_BUFFER_CIRCULAR_SIZE, TXC_BUFFER_LINEAR_NUM, TXC_BUFFER_LINEAR_SIZE, txc_pool_create(), txc_pool_destroy(), TXC_R_NOMEMORY, and TXC_R_SUCCESS.

Referenced by _TXC_global_init().

void txc_buffermgr_destroy ( txc_buffermgr_t **  buffermgrp  ) 

Destroys a buffer manager.

It deallocates all buffers that it manages.

Parameters:
[in,out] buffermgrp The buffer manager to be destroyed.

Definition at line 115 of file buffer.c.

References FREE, and txc_pool_destroy().


Generated on Wed Dec 9 20:32:40 2009 for xCalls by  doxygen 1.4.7