Back to index

nordugrid-arc-nox  1.1.0~rc6
Classes | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
Arc::DataBuffer Class Reference

Represents set of buffers. More...

#include <DataBuffer.h>

Collaboration diagram for Arc::DataBuffer:
Collaboration graph
[legend]

List of all members.

Classes

struct  buf_desc
class  checksum_desc

Public Member Functions

 operator bool () const
 Check if DataBuffer object is initialized.
 DataBuffer (unsigned int size=65536, int blocks=3)
 Contructor.
 DataBuffer (CheckSum *cksum, unsigned int size=65536, int blocks=3)
 Contructor.
 ~DataBuffer ()
 Destructor.
bool set (CheckSum *cksum=NULL, unsigned int size=65536, int blocks=3)
 Reinitialize buffers with different parameters.
int add (CheckSum *cksum)
 Add a checksum object which will compute checksum of buffer.
char * operator[] (int n)
 Direct access to buffer by number.
bool for_read (int &handle, unsigned int &length, bool wait)
 Request buffer for READING INTO it.
bool for_read ()
 Check if there are buffers which can be taken by for_read(). This function checks only for buffers and does not take eof and error conditions into account.
bool is_read (int handle, unsigned int length, unsigned long long int offset)
 Informs object that data was read into buffer.
bool is_read (char *buf, unsigned int length, unsigned long long int offset)
 Informs object that data was read into buffer.
bool for_write (int &handle, unsigned int &length, unsigned long long int &offset, bool wait)
 Request buffer for WRITING FROM it.
bool for_write ()
 Check if there are buffers which can be taken by for_write(). This function checks only for buffers and does not take eof and error conditions into account.
bool is_written (int handle)
 Informs object that data was written from buffer.
bool is_written (char *buf)
 Informs object that data was written from buffer.
bool is_notwritten (int handle)
 Informs object that data was NOT written from buffer (and releases buffer).
bool is_notwritten (char *buf)
 Informs object that data was NOT written from buffer (and releases buffer).
void eof_read (bool v)
 Informs object if there will be no more request for 'read' buffers. v true if no more requests.
void eof_write (bool v)
 Informs object if there will be no more request for 'write' buffers. v true if no more requests.
void error_read (bool v)
 Informs object if error accured on 'read' side.
void error_write (bool v)
 Informs object if error accured on 'write' side.
bool eof_read ()
 Returns true if object was informed about end of transfer on 'read' side.
bool eof_write ()
 Returns true if object was informed about end of transfer on 'write' side.
bool error_read ()
 Returns true if object was informed about error on 'read' side.
bool error_write ()
 Returns true if object was informed about error on 'write' side.
bool error_transfer ()
 Returns true if eror occured inside object.
bool error ()
 Returns true if object was informed about error or internal error occured.
bool wait_any ()
 Wait (max 60 sec.) till any action happens in object. Returns true if action is eof on any side.
bool wait_used ()
 Wait till there are no more used buffers left in object.
bool checksum_valid () const
 Returns true if checksum was successfully computed, returns false if index is not in list.
bool checksum_valid (int index) const
const CheckSumchecksum_object () const
 Returns CheckSum object specified in constructor, returns NULL if index is not in list.
const CheckSumchecksum_object (int index) const
bool wait_eof_read ()
 Wait till end of transfer happens on 'read' side.
bool wait_read ()
 Wait till end of transfer or error happens on 'read' side.
bool wait_eof_write ()
 Wait till end of transfer happens on 'write' side.
bool wait_write ()
 Wait till end of transfer or error happens on 'write' side.
bool wait_eof ()
 Wait till end of transfer happens on any side.
unsigned long long int eof_position () const
 Returns offset following last piece of data transfered.
unsigned int buffer_size () const
 Returns size of buffer in object. If not initialized then this number represents size of default buffer.

Public Attributes

DataSpeed speed
 This object controls transfer speed.

Private Member Functions

bool cond_wait ()

Private Attributes

int set_counter
Glib::Mutex lock
Glib::Cond cond
unsigned long long int eof_pos
buf_descbufs
int bufs_n
bool eof_read_flag
bool eof_write_flag
bool error_read_flag
bool error_write_flag
bool error_transfer_flag
std::list< checksum_descchecksums

Detailed Description

Represents set of buffers.

This class is used used during data transfer using DataPoint classes.

Definition at line 15 of file DataBuffer.h.


Class Documentation

struct Arc::DataBuffer::buf_desc

Definition at line 24 of file DataBuffer.h.

Class Members
unsigned long long int offset
unsigned int size
char * start
bool taken_for_read
bool taken_for_write
unsigned int used

Constructor & Destructor Documentation

Arc::DataBuffer::DataBuffer ( unsigned int  size = 65536,
int  blocks = 3 
)

Contructor.

Parameters:
sizesize of every buffer in bytes.
blocksnumber of buffers.

Definition at line 81 of file DataBuffer.cpp.

                                                      {
    bufs_n = 0;
    bufs = NULL;
    set_counter = 0;
    eof_read_flag = false;
    eof_write_flag = false;
    error_read_flag = false;
    error_write_flag = false;
    error_transfer_flag = false;
    set(NULL, size, blocks);
    eof_pos = 0;
  }
Arc::DataBuffer::DataBuffer ( CheckSum cksum,
unsigned int  size = 65536,
int  blocks = 3 
)

Contructor.

Parameters:
sizesize of every buffer in bytes.
blocksnumber of buffers.
cksumobject which will compute checksum. Should not be destroyed till DataBuffer itself.

Definition at line 94 of file DataBuffer.cpp.

                                     {
    bufs_n = 0;
    bufs = NULL;
    set_counter = 0;
    eof_read_flag = false;
    eof_write_flag = false;
    error_read_flag = false;
    error_write_flag = false;
    error_transfer_flag = false;
    set(cksum, size, blocks);
    eof_pos = 0;
  }

Destructor.

Definition at line 108 of file DataBuffer.cpp.

                          {
    set(NULL, 0, 0);
  }

Member Function Documentation

int Arc::DataBuffer::add ( CheckSum cksum)

Add a checksum object which will compute checksum of buffer.

Parameters:
cksumobject which will compute checksum. Should not be destroyed till DataBuffer itself.
Returns:
integer position in the list of checksum objects.

Definition at line 57 of file DataBuffer.cpp.

                                     {
    if (!cksum)
      return -1;
    lock.lock();
    checksum_desc cs = cksum;
    cs.sum->start();
    for (int i = 0; i < bufs_n; i++)
      if (bufs[i].used != 0)
        if (bufs[i].offset == cs.offset) {
          cs.sum->add(bufs[i].start, bufs[i].used);
          cs.offset += bufs[i].used;
          i = -1;
          cs.ready = true;
        }
        else if (cs.offset < bufs[i].offset)
          cs.ready = false;
    if (eof_read_flag && cs.ready)
      cs.sum->end();
    checksums.push_back(cs);
    int res = checksums.size() - 1;
    lock.unlock();
    return res;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int Arc::DataBuffer::buffer_size ( ) const

Returns size of buffer in object. If not initialized then this number represents size of default buffer.

Definition at line 633 of file DataBuffer.cpp.

                                             {
    if (bufs == NULL)
      return 65536;
    unsigned int size = 0;
    for (int i = 0; i < bufs_n; i++)
      if (size < bufs[i].size)
        size = bufs[i].size;
    return size;
  }

Returns CheckSum object specified in constructor, returns NULL if index is not in list.

Parameters:
indexof the checksum in question.

Definition at line 612 of file DataBuffer.cpp.

                                                    {
    if (checksums.size() != 0)
      return checksums.begin()->sum;
    else
      return NULL;
  }

Here is the caller graph for this function:

const CheckSum * Arc::DataBuffer::checksum_object ( int  index) const

Definition at line 619 of file DataBuffer.cpp.

                                                             {
    if (index < 0)
      return NULL;
    int i = 0;
    for (std::list<checksum_desc>::const_iterator itCheckSum = checksums.begin();
         itCheckSum != checksums.end(); itCheckSum++) {
      if (index == i)
        return itCheckSum->sum;
      i++;
    }

    return NULL;
  }

Returns true if checksum was successfully computed, returns false if index is not in list.

Parameters:
indexof the checksum in question.

Definition at line 591 of file DataBuffer.cpp.

                                        {
    if (checksums.size() != 0)
      return checksums.begin()->ready;
    else
      return false;
  }

Here is the caller graph for this function:

bool Arc::DataBuffer::checksum_valid ( int  index) const

Definition at line 598 of file DataBuffer.cpp.

                                                 {
    if (index < 0)
      return false;
    int i = 0;
    for (std::list<checksum_desc>::const_iterator itCheckSum = checksums.begin();
         itCheckSum != checksums.end(); itCheckSum++) {
      if (index == i)
        return itCheckSum->ready;
      i++;
    }

    return false;
  }
bool Arc::DataBuffer::cond_wait ( ) [private]

Definition at line 246 of file DataBuffer.cpp.

                             {
    // Wait for any event
    int tmp = set_counter;
    bool eof_read_flag_tmp = eof_read_flag;
    bool eof_write_flag_tmp = eof_write_flag;
    // cond.wait(lock);
    bool err = false;
    for (;;) {
      if (!speed.transfer())
        if ((!(error_read_flag || error_write_flag)) &&
            (!(eof_read_flag && eof_write_flag)))
          error_transfer_flag = true;
      if (eof_read_flag && eof_write_flag) { // there wil be no more events
        lock.unlock();
        Glib::Thread::yield();
        lock.lock();
        return true;
      }
      if (eof_read_flag_tmp != eof_read_flag)
        return true;
      if (eof_write_flag_tmp != eof_write_flag)
        return true;
      if (error())
        return false; // useless to wait for - better fail
      if (set_counter != tmp)
        return false;
      if (err)
        break; // Some event
      int t = 60;
      Glib::TimeVal stime;
      stime.assign_current_time();
      // Using timeout to workaround lost signal
      err = cond.timed_wait(lock, stime + t);
    }
    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned long long int Arc::DataBuffer::eof_position ( ) const [inline]

Returns offset following last piece of data transfered.

Definition at line 206 of file DataBuffer.h.

                                                {
      return eof_pos;
    }

Here is the caller graph for this function:

void Arc::DataBuffer::eof_read ( bool  v)

Informs object if there will be no more request for 'read' buffers. v true if no more requests.

Definition at line 132 of file DataBuffer.cpp.

                                     {
    lock.lock();
    if (eof_)
      for (std::list<checksum_desc>::iterator itCheckSum = checksums.begin();
           itCheckSum != checksums.end(); itCheckSum++)
        if (itCheckSum->sum)
          itCheckSum->sum->end();
    eof_read_flag = eof_;
    cond.broadcast();
    lock.unlock();
  }

Here is the caller graph for this function:

Returns true if object was informed about end of transfer on 'read' side.

Definition at line 112 of file DataBuffer.cpp.

                            {
    return eof_read_flag;
  }
void Arc::DataBuffer::eof_write ( bool  v)

Informs object if there will be no more request for 'write' buffers. v true if no more requests.

Definition at line 144 of file DataBuffer.cpp.

                                      {
    lock.lock();
    eof_write_flag = eof_;
    cond.broadcast();
    lock.unlock();
  }

Here is the caller graph for this function:

Returns true if object was informed about end of transfer on 'write' side.

Definition at line 116 of file DataBuffer.cpp.

                             {
    return eof_write_flag;
  }

Returns true if object was informed about error or internal error occured.

Definition at line 151 of file DataBuffer.cpp.

Here is the caller graph for this function:

void Arc::DataBuffer::error_read ( bool  v)

Informs object if error accured on 'read' side.

Parameters:
vtrue if error.

Definition at line 155 of file DataBuffer.cpp.

                                         {
    lock.lock();
    // error_read_flag=error_;
    if (error_) {
      if (!(error_write_flag || error_transfer_flag))
        error_read_flag = true;
      for (std::list<checksum_desc>::iterator itCheckSum = checksums.begin();
           itCheckSum != checksums.end(); itCheckSum++)
        if (itCheckSum->sum)
          itCheckSum->sum->end();
      eof_read_flag = true;
    }
    else
      error_read_flag = false;
    cond.broadcast();
    lock.unlock();
  }

Here is the caller graph for this function:

Returns true if object was informed about error on 'read' side.

Definition at line 124 of file DataBuffer.cpp.

                              {
    return error_read_flag;
  }

Returns true if eror occured inside object.

Definition at line 120 of file DataBuffer.cpp.

                                  {
    return error_transfer_flag;
  }

Here is the caller graph for this function:

void Arc::DataBuffer::error_write ( bool  v)

Informs object if error accured on 'write' side.

Parameters:
vtrue if error.

Definition at line 173 of file DataBuffer.cpp.

                                          {
    lock.lock();
    // error_write_flag=error_;
    if (error_) {
      if (!(error_read_flag || error_transfer_flag))
        error_write_flag = true;
      eof_write_flag = true;
    }
    else
      error_write_flag = false;
    cond.broadcast();
    lock.unlock();
  }

Here is the caller graph for this function:

Returns true if object was informed about error on 'write' side.

Definition at line 128 of file DataBuffer.cpp.

                               {
    return error_write_flag;
  }
bool Arc::DataBuffer::for_read ( int &  handle,
unsigned int &  length,
bool  wait 
)

Request buffer for READING INTO it.

Parameters:
handlereturns buffer's number.
lengthreturns size of buffer
waitif true and there are no free buffers, method will wait for one.
Returns:
true on success

Definition at line 297 of file DataBuffer.cpp.

                                                                        {
    lock.lock();
    if (bufs == NULL) {
      lock.unlock();
      return false;
    }
    for (;;) {
      if (error()) { /* errors detected/set - any continuation is unusable */
        lock.unlock();
        return false;
      }
      for (int i = 0; i < bufs_n; i++)
        if ((!bufs[i].taken_for_read) && (!bufs[i].taken_for_write) &&
            (bufs[i].used == 0)) {
          if (bufs[i].start == NULL) {
            bufs[i].start = (char*)malloc(bufs[i].size);
            if (bufs[i].start == NULL)
              continue;
          }
          handle = i;
          bufs[i].taken_for_read = true;
          length = bufs[i].size;
          cond.broadcast();
          lock.unlock();
          return true;
        }
      /* suitable block not found - wait for changes or quit */
      if (eof_write_flag) { /* writing side quited, no need to wait */
        lock.unlock();
        return false;
      }
      if (!wait) {
        lock.unlock();
        return false;
      }
      if (!cond_wait()) {
        lock.unlock();
        return false;
      }
    }
    lock.unlock();
    return false;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Check if there are buffers which can be taken by for_read(). This function checks only for buffers and does not take eof and error conditions into account.

Definition at line 283 of file DataBuffer.cpp.

                            {
    if (bufs == NULL)
      return false;
    lock.lock();
    for (int i = 0; i < bufs_n; i++)
      if ((!bufs[i].taken_for_read) && (!bufs[i].taken_for_write) &&
          (bufs[i].used == 0)) {
        lock.unlock();
        return true;
      }
    lock.unlock();
    return false;
  }
bool Arc::DataBuffer::for_write ( int &  handle,
unsigned int &  length,
unsigned long long int &  offset,
bool  wait 
)

Request buffer for WRITING FROM it.

Parameters:
handlereturns buffer's number.
lengthreturns size of buffer
waitif true and there are no free buffers, method will wait for one.

Definition at line 412 of file DataBuffer.cpp.

                                                                        {
    lock.lock();
    if (bufs == NULL) {
      lock.unlock();
      return false;
    }
    for (;;) {
      if (error()) { /* internal/external errors - no need to continue */
        lock.unlock();
        return false;
      }
      bool have_for_read = false;
      bool have_unused = false;
      unsigned long long int min_offset = (unsigned long long int)(-1);
      handle = -1;
      for (int i = 0; i < bufs_n; i++) {
        if (bufs[i].taken_for_read)
          have_for_read = true;
        if ((!bufs[i].taken_for_read) && (!bufs[i].taken_for_write) &&
            (bufs[i].used != 0))
          if (bufs[i].offset < min_offset) {
            min_offset = bufs[i].offset;
            handle = i;
          }
        if (bufs[i].taken_for_read || (bufs[i].used == 0))
          have_unused = true;
      }
      if (handle != -1) {
        bool keep_buffers = false;
        for (std::list<checksum_desc>::iterator itCheckSum = checksums.begin();
             itCheckSum != checksums.end(); itCheckSum++)
          if ((!itCheckSum->ready) && (bufs[handle].offset >= itCheckSum->offset)) {
            keep_buffers = true;
            break;
          }

        if (keep_buffers)
          /* try to keep buffers as long as possible for checksuming */
          if (have_unused && (!eof_read_flag)) {
            /* still have chances to get that block */
            if (!wait) {
              lock.unlock();
              return false;
            }
            if (!cond_wait()) {
              lock.unlock();
              return false;
            }
            continue;
          }

        bufs[handle].taken_for_write = true;
        length = bufs[handle].used;
        offset = bufs[handle].offset;
        cond.broadcast();
        lock.unlock();
        return true;
      }
      if (eof_read_flag && (!have_for_read)) {
        lock.unlock();
        return false;
      }
      /* suitable block not found - wait for changes or quit */
      if (!wait) {
        lock.unlock();
        return false;
      }
      if (!cond_wait()) {
        lock.unlock();
        return false;
      }
    }
    lock.unlock();
    return false;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Check if there are buffers which can be taken by for_write(). This function checks only for buffers and does not take eof and error conditions into account.

Definition at line 396 of file DataBuffer.cpp.

                             {
    if (bufs == NULL)
      return false;
    lock.lock();
    for (int i = 0; i < bufs_n; i++)
      if ((!bufs[i].taken_for_read) && (!bufs[i].taken_for_write) &&
          (bufs[i].used != 0)) {
        lock.unlock();
        return true;
      }
    lock.unlock();
    return false;
  }
bool Arc::DataBuffer::is_notwritten ( int  handle)

Informs object that data was NOT written from buffer (and releases buffer).

Parameters:
handlebuffer's number.

Definition at line 538 of file DataBuffer.cpp.

                                           {
    lock.lock();
    if (bufs == NULL) {
      lock.unlock();
      return false;
    }
    if (handle >= bufs_n) {
      lock.unlock();
      return false;
    }
    if (!bufs[handle].taken_for_write) {
      lock.unlock();
      return false;
    }
    bufs[handle].taken_for_write = false;
    cond.broadcast();
    lock.unlock();
    return true;
  }

Here is the caller graph for this function:

bool Arc::DataBuffer::is_notwritten ( char *  buf)

Informs object that data was NOT written from buffer (and releases buffer).

Parameters:
buf- address of buffer

Definition at line 500 of file DataBuffer.cpp.

                                          {
    lock.lock();
    for (int i = 0; i < bufs_n; i++)
      if (bufs[i].start == buf) {
        lock.unlock();
        return is_notwritten(i);
      }
    lock.unlock();
    return false;
  }

Here is the call graph for this function:

bool Arc::DataBuffer::is_read ( int  handle,
unsigned int  length,
unsigned long long int  offset 
)

Informs object that data was read into buffer.

Parameters:
handlebuffer's number.
lengthamount of data.
offsetoffset in stream, file, etc.

Definition at line 353 of file DataBuffer.cpp.

                                                          {
    lock.lock();
    if (bufs == NULL) {
      lock.unlock();
      return false;
    }
    if (handle >= bufs_n) {
      lock.unlock();
      return false;
    }
    if (!bufs[handle].taken_for_read) {
      lock.unlock();
      return false;
    }
    if (length > bufs[handle].size) {
      lock.unlock();
      return false;
    }
    bufs[handle].taken_for_read = false;
    bufs[handle].used = length;
    bufs[handle].offset = offset;
    if ((offset + length) > eof_pos)
      eof_pos = offset + length;
    /* checksum on the fly */
    for (std::list<checksum_desc>::iterator itCheckSum = checksums.begin();
         itCheckSum != checksums.end(); itCheckSum++)
      if ((itCheckSum->sum != NULL) && (offset == itCheckSum->offset))
        for (int i = handle; i < bufs_n; i++)
          if (bufs[i].used != 0)
            if (bufs[i].offset == itCheckSum->offset) {
              itCheckSum->sum->add(bufs[i].start, bufs[i].used);
              itCheckSum->offset += bufs[i].used;
              i = -1;
              itCheckSum->ready = true;
            }
            else if (itCheckSum->offset < bufs[i].offset)
              itCheckSum->ready = false;
    cond.broadcast();
    lock.unlock();
    return true;
  }

Here is the caller graph for this function:

bool Arc::DataBuffer::is_read ( char *  buf,
unsigned int  length,
unsigned long long int  offset 
)

Informs object that data was read into buffer.

Parameters:
buf- address of buffer
lengthamount of data.
offsetoffset in stream, file, etc.

Definition at line 341 of file DataBuffer.cpp.

                                                          {
    lock.lock();
    for (int i = 0; i < bufs_n; i++)
      if (bufs[i].start == buf) {
        lock.unlock();
        return is_read(i, length, offset);
      }
    lock.unlock();
    return false;
  }

Here is the call graph for this function:

bool Arc::DataBuffer::is_written ( int  handle)

Informs object that data was written from buffer.

Parameters:
handlebuffer's number.

Definition at line 511 of file DataBuffer.cpp.

                                        {
    lock.lock();
    if (bufs == NULL) {
      lock.unlock();
      return false;
    }
    if (handle >= bufs_n) {
      lock.unlock();
      return false;
    }
    if (!bufs[handle].taken_for_write) {
      lock.unlock();
      return false;
    }
    /* speed control */
    if (!speed.transfer(bufs[handle].used))
      if ((!(error_read_flag || error_write_flag)) &&
          (!(eof_read_flag && eof_write_flag)))
        error_transfer_flag = true;
    bufs[handle].taken_for_write = false;
    bufs[handle].used = 0;
    bufs[handle].offset = 0;
    cond.broadcast();
    lock.unlock();
    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool Arc::DataBuffer::is_written ( char *  buf)

Informs object that data was written from buffer.

Parameters:
buf- address of buffer

Definition at line 489 of file DataBuffer.cpp.

                                       {
    lock.lock();
    for (int i = 0; i < bufs_n; i++)
      if (bufs[i].start == buf) {
        lock.unlock();
        return is_written(i);
      }
    lock.unlock();
    return false;
  }

Here is the call graph for this function:

Arc::DataBuffer::operator bool ( void  ) const [inline]

Check if DataBuffer object is initialized.

Definition at line 76 of file DataBuffer.h.

                          {
      return (bufs != 0);
    }
char * Arc::DataBuffer::operator[] ( int  n)

Direct access to buffer by number.

Definition at line 558 of file DataBuffer.cpp.

                                        {
    lock.lock();
    if ((block < 0) || (block >= bufs_n)) {
      lock.unlock();
      return NULL;
    }
    char *tmp = bufs[block].start;
    lock.unlock();
    return tmp;
  }
bool Arc::DataBuffer::set ( CheckSum cksum = NULL,
unsigned int  size = 65536,
int  blocks = 3 
)

Reinitialize buffers with different parameters.

Parameters:
sizesize of every buffer in bytes.
blocksnumber of buffers.
cksumobject which will compute checksum. Should not be destroyed till DataBuffer itself.

Definition at line 14 of file DataBuffer.cpp.

                                                                     {
    lock.lock();
    if (blocks < 0) {
      lock.unlock();
      return false;
    }
    if (bufs != NULL) {
      for (int i = 0; i < bufs_n; i++)
        if (bufs[i].start)
          free(bufs[i].start);
      free(bufs);
      bufs_n = 0;
      bufs = NULL;
      set_counter++;
      cond.broadcast(); /* make all waiting loops to exit */
    }
    if ((size == 0) || (blocks == 0)) {
      lock.unlock();
      return true;
    }
    bufs = (buf_desc*)malloc(sizeof(buf_desc) * blocks);
    if (bufs == NULL) {
      lock.unlock();
      return false;
    }
    bufs_n = blocks;
    for (int i = 0; i < blocks; i++) {
      bufs[i].start = NULL;
      bufs[i].taken_for_read = false;
      bufs[i].taken_for_write = false;
      bufs[i].size = size;
      bufs[i].used = 0;
      bufs[i].offset = 0;
    }
    //checksum = cksum;
    checksums.clear();
    checksums.push_back(checksum_desc(cksum));
    if (cksum)
      cksum->start();
    lock.unlock();
    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Wait (max 60 sec.) till any action happens in object. Returns true if action is eof on any side.

Definition at line 569 of file DataBuffer.cpp.

                            {
    lock.lock();
    bool res = cond_wait();
    lock.unlock();
    return res;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Wait till end of transfer happens on any side.

Definition at line 235 of file DataBuffer.cpp.

                            {
    lock.lock();
    for (;;) {
      if (eof_read_flag && eof_write_flag)
        break;
      cond.wait(lock);
    }
    lock.unlock();
    return true;
  }

Here is the caller graph for this function:

Wait till end of transfer happens on 'read' side.

Definition at line 187 of file DataBuffer.cpp.

                                 {
    lock.lock();
    for (;;) {
      if (eof_read_flag)
        break;
      cond.wait(lock);
    }
    lock.unlock();
    return true;
  }

Here is the caller graph for this function:

Wait till end of transfer happens on 'write' side.

Definition at line 211 of file DataBuffer.cpp.

                                  {
    lock.lock();
    for (;;) {
      if (eof_write_flag)
        break;
      cond.wait(lock);
    }
    lock.unlock();
    return true;
  }

Here is the caller graph for this function:

Wait till end of transfer or error happens on 'read' side.

Definition at line 198 of file DataBuffer.cpp.

                             {
    lock.lock();
    for (;;) {
      if (eof_read_flag)
        break;
      if (error_read_flag)
        break;
      cond.wait(lock);
    }
    lock.unlock();
    return true;
  }

Here is the caller graph for this function:

Wait till there are no more used buffers left in object.

Definition at line 576 of file DataBuffer.cpp.

                             {
    lock.lock();
    for (int i = 0; i < bufs_n; i++)
      if ((bufs[i].taken_for_read) || (bufs[i].taken_for_write) ||
          (bufs[i].used != 0)) {
        if (!cond_wait()) {
          lock.unlock();
          return false;
        }
        i = -1;
      }
    lock.unlock();
    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Wait till end of transfer or error happens on 'write' side.

Definition at line 222 of file DataBuffer.cpp.

                              {
    lock.lock();
    for (;;) {
      if (eof_write_flag)
        break;
      if (error_write_flag)
        break;
      cond.wait(lock);
    }
    lock.unlock();
    return true;
  }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 42 of file DataBuffer.h.

int Arc::DataBuffer::bufs_n [private]

Definition at line 44 of file DataBuffer.h.

Definition at line 70 of file DataBuffer.h.

Glib::Cond Arc::DataBuffer::cond [private]

Definition at line 22 of file DataBuffer.h.

unsigned long long int Arc::DataBuffer::eof_pos [private]

Definition at line 40 of file DataBuffer.h.

Definition at line 47 of file DataBuffer.h.

Definition at line 49 of file DataBuffer.h.

Definition at line 51 of file DataBuffer.h.

Definition at line 55 of file DataBuffer.h.

Definition at line 53 of file DataBuffer.h.

Glib::Mutex Arc::DataBuffer::lock [private]

Definition at line 21 of file DataBuffer.h.

Definition at line 18 of file DataBuffer.h.

This object controls transfer speed.

Definition at line 74 of file DataBuffer.h.


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