Home | History | Annotate | Download | only in base
      1 /*
      2  * Copyright (C) 2013 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef ART_RUNTIME_BASE_ARENA_BIT_VECTOR_H_
     18 #define ART_RUNTIME_BASE_ARENA_BIT_VECTOR_H_
     19 
     20 #include "base/arena_object.h"
     21 #include "base/bit_vector.h"
     22 
     23 namespace art {
     24 
     25 class ArenaAllocator;
     26 class ScopedArenaAllocator;
     27 
     28 /*
     29  * A BitVector implementation that uses Arena allocation.
     30  */
     31 class ArenaBitVector : public BitVector, public ArenaObject<kArenaAllocGrowableBitMap> {
     32  public:
     33   template <typename Allocator>
     34   static ArenaBitVector* Create(Allocator* arena,
     35                                 uint32_t start_bits,
     36                                 bool expandable,
     37                                 ArenaAllocKind kind = kArenaAllocGrowableBitMap) {
     38     void* storage = arena->template Alloc<ArenaBitVector>(kind);
     39     return new (storage) ArenaBitVector(arena, start_bits, expandable, kind);
     40   }
     41 
     42   ArenaBitVector(ArenaAllocator* arena,
     43                  uint32_t start_bits,
     44                  bool expandable,
     45                  ArenaAllocKind kind = kArenaAllocGrowableBitMap);
     46   ArenaBitVector(ScopedArenaAllocator* arena,
     47                  uint32_t start_bits,
     48                  bool expandable,
     49                  ArenaAllocKind kind = kArenaAllocGrowableBitMap);
     50   ~ArenaBitVector() {}
     51 
     52  private:
     53   DISALLOW_COPY_AND_ASSIGN(ArenaBitVector);
     54 };
     55 
     56 }  // namespace art
     57 
     58 #endif  // ART_RUNTIME_BASE_ARENA_BIT_VECTOR_H_
     59