Coverage for /Syzygy/agent/asan/circular_queue_impl.h

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%40400.C++source

Line-by-line coverage:

   1    :  // Copyright 2014 Google Inc. All Rights Reserved.
   2    :  //
   3    :  // Licensed under the Apache License, Version 2.0 (the "License");
   4    :  // you may not use this file except in compliance with the License.
   5    :  // You may obtain a copy of the License at
   6    :  //
   7    :  //     http://www.apache.org/licenses/LICENSE-2.0
   8    :  //
   9    :  // Unless required by applicable law or agreed to in writing, software
  10    :  // distributed under the License is distributed on an "AS IS" BASIS,
  11    :  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12    :  // See the License for the specific language governing permissions and
  13    :  // limitations under the License.
  14    :  //
  15    :  // Internal implementation details for circular_queue.h. Not meant to
  16    :  // be included directly.
  17    :  
  18    :  #ifndef SYZYGY_AGENT_ASAN_CIRCULAR_QUEUE_IMPL_H_
  19    :  #define SYZYGY_AGENT_ASAN_CIRCULAR_QUEUE_IMPL_H_
  20    :  
  21    :  #include "base/logging.h"
  22    :  #include "syzygy/agent/asan/memory_notifier.h"
  23    :  
  24    :  namespace agent {
  25    :  namespace asan {
  26    :  
  27    :  template<typename T, typename Alloc>
  28    :  CircularQueue<T, Alloc>::CircularQueue(size_t max_capacity)
  29  E :      : head_(0u), tail_(0u), size_(0u) {
  30  E :    buffer_.resize(max_capacity);
  31  E :  }
  32    :  
  33    :  template<typename T, typename Alloc>
  34    :  CircularQueue<T, Alloc>::CircularQueue(
  35    :      size_t max_capacity, const Alloc& alloc)
  36    :      : buffer_(alloc),
  37    :        head_(0u),
  38    :        tail_(0u),
  39  E :        size_(0u) {
  40  E :    buffer_.resize(max_capacity);
  41  E :  }
  42    :  
  43    :  template<typename T, typename Alloc>
  44  E :  bool CircularQueue<T, Alloc>::push(const T& elem) {
  45  E :    DCHECK_LE(size_, buffer_.size());
  46  E :    if (size_ == buffer_.size())
  47  E :      return false;
  48  E :    DCHECK_LT(tail_, buffer_.size());
  49  E :    buffer_[tail_++] = elem;
  50  E :    if (tail_ >= buffer_.size())
  51  E :      tail_ = 0;
  52  E :    ++size_;
  53  E :    return true;
  54  E :  }
  55    :  
  56    :  template<typename T, typename Alloc>
  57  E :  bool CircularQueue<T, Alloc>::pop() {
  58  E :    if (empty())
  59  E :      return false;
  60  E :    DCHECK_LT(head_, buffer_.size());
  61  E :    ++head_;
  62  E :    if (head_ == buffer_.size())
  63  E :      head_ = 0;
  64  E :    --size_;
  65  E :    return true;
  66  E :  }
  67    :  
  68    :  template<typename T, typename Alloc>
  69  E :  const T& CircularQueue<T, Alloc>::front() const {
  70  E :    DCHECK(!empty());
  71  E :    return buffer_[head_];
  72  E :  }
  73    :  
  74    :  template<typename T, typename Alloc>
  75  E :  size_t CircularQueue<T, Alloc>::size() const {
  76  E :    return size_;
  77  E :  }
  78    :  
  79    :  template<typename T, typename Alloc>
  80  E :  bool CircularQueue<T, Alloc>::empty() const {
  81  E :    return size() == 0;
  82  E :  }
  83    :  
  84    :  template<typename T, typename Alloc>
  85  E :  size_t CircularQueue<T, Alloc>::max_capacity() const {
  86  E :    return buffer_.size();
  87  E :  }
  88    :  
  89    :  }  // namespace asan
  90    :  }  // namespace agent
  91    :  
  92    :  #endif  // SYZYGY_AGENT_ASAN_CIRCULAR_QUEUE_IMPL_H_

Coverage information generated Thu Jan 14 17:40:38 2016.