libdap::MarshallerThread Class Reference

`#include <MarshallerThread.h>`

## Public Member Functions

int & | get_child_thread_count ()
pthread_cond_t & | get_cond ()
pthread_mutex_t & | get_mutex ()
void | increment_child_thread_count ()
void | start_thread (void *(*thread)(void *arg), int fd, char *byte_buf, std::streamsize bytes_written)
void | start_thread (void *(*thread)(void *arg), std::ostream &out, char *byte_buf, std::streamsize bytes_written)

## Static Public Member Functions

static void * | write_thread (void *arg)
static void * | write_thread_part (void *arg)

## Detailed Description

Implement a multi-threaded data transmission sub-system for libdap. This class makes it fairly painless to send data using a child thread so that the main thread can be used to read the next chunk of data while whatever has been read to this point is sent over the wire.

This code is used by XDRStreamMarshaller and (soon) D4StreamMarshaller.

Definition at line 95 of file MarshallerThread.h.

## Constructor & Destructor Documentation

## MarshallerThread()

MarshallerThread::MarshallerThread | ( |  | ) |

Definition at line 149 of file MarshallerThread.cc.

## ~MarshallerThread()

MarshallerThread::~MarshallerThread | ( |  | ) |

virtual

Definition at line 161 of file MarshallerThread.cc.

## Member Function Documentation

## get_child_thread_count()

int & libdap::MarshallerThread::get_child_thread_count | ( |  | ) |

inline

Definition at line 146 of file MarshallerThread.h.

## get_cond()

pthread_cond_t & libdap::MarshallerThread::get_cond | ( |  | ) |

inline

Definition at line 144 of file MarshallerThread.h.

## get_mutex()

pthread_mutex_t & libdap::MarshallerThread::get_mutex | ( |  | ) |

inline

Definition at line 143 of file MarshallerThread.h.

## increment_child_thread_count()

void libdap::MarshallerThread::increment_child_thread_count | ( |  | ) |

inline

Definition at line 147 of file MarshallerThread.h.

## start_thread() [1/2]

void MarshallerThread::start_thread | ( | void *(* | thread )(void *arg),
|  | int | fd,
|  | char * | byte_buf,
|  | std::streamsize | bytes )

Write 'bytes' bytes from 'byte_buf' to the file descriptor 'fd'.

Definition at line 194 of file MarshallerThread.cc.

## start_thread() [2/2]

void MarshallerThread::start_thread | ( | void *(* | thread )(void *arg),
|  | std::ostream & | out,
|  | char * | byte_buf,
|  | std::streamsize | bytes )

Start the child thread, using the arguments given. This will write 'bytes' bytes from 'byte_buf' to the output stream 'out'

Definition at line 184 of file MarshallerThread.cc.

## write_thread()

void * MarshallerThread::write_thread | ( | void * | arg | ) |

static

This static method is used to write data to the ostream referenced by the ostream element of write_args. This is used by start_thread() and passed to pthread_create()

Note
  The write_args argument may contain either a file descriptor (d_out_file) or an ostream& (d_out). If the file descriptor is not -1, then use that, else use the ostream reference.

Definition at line 210 of file MarshallerThread.cc.

## write_thread_part()

void * MarshallerThread::write_thread_part | ( | void * | arg | ) |

static

This static method is used to write data to the ostream referenced by the ostream element of write_args. This is used by start_thread() and passed to pthread_create()

Note
  This differs from MarshallerThread::write_thread() in that it writes data starting after the four-byte length prefix that XDR adds to the data. It is used for the put_vector_part() calls in XDRStreamMarshaller.

Returns
  0 if successful, -1 otherwise.

Definition at line 266 of file MarshallerThread.cc.

The documentation for this class was generated from the following files:

- MarshallerThread.h
- MarshallerThread.cc