Back to index

nordugrid-arc-nox  1.1.0~rc6
Classes | Public Member Functions | Private Attributes
Arc::ChunkControl Class Reference
Collaboration diagram for Arc::ChunkControl:
Collaboration graph
[legend]

List of all members.

Classes

struct  chunk_t

Public Member Functions

 ChunkControl (uint64_t size=UINT64_MAX)
 ~ChunkControl ()
bool Get (uint64_t &start, uint64_t &length)
void Claim (uint64_t start, uint64_t length)
void Unclaim (uint64_t start, uint64_t length)

Private Attributes

std::list< chunk_tchunks_
Glib::Mutex lock_

Detailed Description

Definition at line 36 of file DataPointHTTP.cpp.


Class Documentation

struct Arc::ChunkControl::chunk_t

Definition at line 38 of file DataPointHTTP.cpp.

Class Members
uint64_t end
uint64_t start

Constructor & Destructor Documentation

Arc::ChunkControl::ChunkControl ( uint64_t  size = UINT64_MAX)

Definition at line 129 of file DataPointHTTP.cpp.

                                       {
    chunk_t chunk = {
      0, UINT64_MAX
    };
    chunks_.push_back(chunk);
  }

Definition at line 136 of file DataPointHTTP.cpp.

{}

Member Function Documentation

void Arc::ChunkControl::Claim ( uint64_t  start,
uint64_t  length 
)

Definition at line 159 of file DataPointHTTP.cpp.

                                                          {
    if (length == 0)
      return;
    uint64_t end = start + length;
    lock_.lock();
    for (std::list<chunk_t>::iterator c = chunks_.begin();
         c != chunks_.end();) {
      if (end <= c->start)
        break;
      if ((start <= c->start) && (end >= c->end)) {
        start = c->end;
        length = end - start;
        c = chunks_.erase(c);
        if (length > 0)
          continue;
        break;
      }
      if ((start > c->start) && (end < c->end)) {
        chunk_t chunk;
        chunk.start = c->start;
        chunk.end = start;
        c->start = end;
        chunks_.insert(c, chunk);
        break;
      }
      if ((start <= c->start) && (end < c->end) && (end > c->start)) {
        c->start = end;
        break;
      }
      if ((start > c->start) && (start < c->end) && (end >= c->end)) {
        uint64_t start_ = c->end;
        c->end = start;
        start = start_;
        length = end - start;
        ++c;
        if (length > 0)
          continue;
        break;
      }
      ++c;
    }
    lock_.unlock();
  }

Here is the caller graph for this function:

bool Arc::ChunkControl::Get ( uint64_t &  start,
uint64_t &  length 
)

Definition at line 138 of file DataPointHTTP.cpp.

                                                          {
    if (length == 0)
      return false;
    lock_.lock();
    std::list<chunk_t>::iterator c = chunks_.begin();
    if (c == chunks_.end()) {
      lock_.unlock();
      return false;
    }
    start = c->start;
    uint64_t l = (c->end) - (c->start);
    if (l <= length) {
      length = l;
      chunks_.erase(c);
    }
    else
      c->start += length;
    lock_.unlock();
    return true;
  }

Here is the caller graph for this function:

void Arc::ChunkControl::Unclaim ( uint64_t  start,
uint64_t  length 
)

Definition at line 203 of file DataPointHTTP.cpp.

                                                            {
    if (length == 0)
      return;
    uint64_t end = start + length;
    lock_.lock();
    for (std::list<chunk_t>::iterator c = chunks_.begin();
         c != chunks_.end(); ++c) {
      if ((end >= c->start) && (end <= c->end)) {
        if (start < c->start)
          c->start = start;
        lock_.unlock();
        return;
      }
      if ((start <= c->end) && (start >= c->start)) {
        if (end > c->end) {
          c->end = end;
          std::list<chunk_t>::iterator c_ = c;
          ++c_;
          while (c_ != chunks_.end())
            if (c->end >= c_->start) {
              if (c_->end >= c->end) {
                c->end = c_->end;
                break;
              }
              c_ = chunks_.erase(c_);
            }
            else
              break;
        }
        lock_.unlock();
        return;
      }
      if ((start <= c->start) && (end >= c->end)) {
        c->start = start;
        if (end > c->end) {
          c->end = end;
          std::list<chunk_t>::iterator c_ = c;
          ++c_;
          while (c_ != chunks_.end())
            if (c->end >= c_->start) {
              if (c_->end >= c->end) {
                c->end = c_->end;
                break;
              }
              c_ = chunks_.erase(c_);
            }
            else
              break;
        }
        lock_.unlock();
        return;
      }
      if (end < c->start) {
        chunk_t chunk = {
          start, end
        };
        chunks_.insert(c, chunk);
        lock_.unlock();
        return;
      }
    }
    lock_.unlock();
  }

Here is the caller graph for this function:


Member Data Documentation

std::list<chunk_t> Arc::ChunkControl::chunks_ [private]

Definition at line 42 of file DataPointHTTP.cpp.

Glib::Mutex Arc::ChunkControl::lock_ [private]

Definition at line 43 of file DataPointHTTP.cpp.


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