[an error occurred while processing this directive] recursive grep: bbuffer.h File Reference
Friedrich-Alexander-Universität UnivisSuche FAU-Logo
Techn. Fakultät Willkommen am Department Informatik FAU-Logo
Logo I4
Lehrstuhl für Informatik 4
[an error occurred while processing this directive] [an error occurred while processing this directive]
Department Informatik

process list

bbuffer.h File Reference

Bounded Buffer implementation to manage open files that supports multiple readers but only a single writer. More...

#include <stdio.h>

Go to the source code of this file.

Typedefs

typedef struct BNDBUF BNDBUF

Functions

BNDBUFbb_init (unsigned int size)
 Creates a new Bounded Buffer.
void bb_del (BNDBUF *bb)
 Destroys a Bounded Buffer.
void bb_get (BNDBUF *bb, FILE **fp, const char **filename)
 Retrieve an element from the bounded buffer.
void bb_add (BNDBUF *bb, FILE *fp, const char *filename)
 Add an element to the bounded buffer.


Detailed Description

Bounded Buffer implementation to manage open files that supports multiple readers but only a single writer.

The bbuffer module uses the sem module API to synchronize concurrent access of readers and writers to the bounded buffer. An open file is constituted by a FILE * and the filename of the corresponding file.


Typedef Documentation

typedef struct BNDBUF BNDBUF

Opaque type of a Bounded Buffer.


Function Documentation

void bb_add ( BNDBUF bb,
FILE *  fp,
const char *  filename 
)

Add an element to the bounded buffer.

This function adds an element to the bounded buffer. If the bounded buffer is full, the function blocks until an element is removed from the buffer.

Parameters:
bb Handle of the bounded buffer.
fp Handle to the opened file.
filename Name of the file.

void bb_del ( BNDBUF bb  ) 

Destroys a Bounded Buffer.

All resources associated with the bounded buffer are released.

Parameters:
bb Handle of the bounded buffer that shall be freed.

void bb_get ( BNDBUF bb,
FILE **  fp,
const char **  filename 
)

Retrieve an element from the bounded buffer.

This function removes an element from the bounded buffer. If the bounded buffer is empty, the function blocks until an element is added to the buffer.

Parameters:
bb Handle of the bounded buffer.
fp Pointer to a FILE pointer where bb_get will store the removed FILE handle.
filename Pointer to a char pointer where bb_get will store the removed filename.

BNDBUF* bb_init ( unsigned int  size  ) 

Creates a new Bounded Buffer.

This function creates a new bounded buffer and all the helper data structures required by the buffer, including semaphores for synchronization. If an error occurs during the initialization the implementation shall free all resources already allocated by then.

Parameters:
size The number of elements that can be stored in the bounded buffer.
Returns:
handle for the created bounded buffer, or NULL if an error occured.

  Impressum   Datenschutz Stand: 2010-06-17 17:02   MS