1 /** @file
2 
3   @section license License
4 
5   Licensed to the Apache Software Foundation (ASF) under one
6   or more contributor license agreements.  See the NOTICE file
7   distributed with this work for additional information
8   regarding copyright ownership.  The ASF licenses this file
9   to you under the Apache License, Version 2.0 (the
10   "License"); you may not use this file except in compliance
11   with the License.  You may obtain a copy of the License at
12 
13       http://www.apache.org/licenses/LICENSE-2.0
14 
15   Unless required by applicable law or agreed to in writing, software
16   distributed under the License is distributed on an "AS IS" BASIS,
17   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   See the License for the specific language governing permissions and
19   limitations under the License.
20  */
21 
22 #include <P_RefCountCache.h>
23 
24 // Since the hashing values are all fixed size, we can simply use a classAllocator to avoid mallocs
25 static ClassAllocator<RefCountCacheHashEntry> refCountCacheHashingValueAllocator("refCountCacheHashingValueAllocator");
26 
27 ClassAllocator<PriorityQueueEntry<RefCountCacheHashEntry *>> expiryQueueEntry("expiryQueueEntry");
28 
29 RefCountCacheHashEntry *
alloc()30 RefCountCacheHashEntry::alloc()
31 {
32   return refCountCacheHashingValueAllocator.alloc();
33 }
34 
35 void
dealloc(RefCountCacheHashEntry * e)36 RefCountCacheHashEntry::dealloc(RefCountCacheHashEntry *e)
37 {
38   return refCountCacheHashingValueAllocator.free(e);
39 }
40 
RefCountCacheHeader(ts::VersionNumber object_version)41 RefCountCacheHeader::RefCountCacheHeader(ts::VersionNumber object_version) : object_version(object_version){};
42 
43 bool
operator ==(const RefCountCacheHeader other) const44 RefCountCacheHeader::operator==(const RefCountCacheHeader other) const
45 {
46   return this->magic == other.magic && this->version == other.version;
47 }
48 
49 bool
compatible(RefCountCacheHeader * other) const50 RefCountCacheHeader::compatible(RefCountCacheHeader *other) const
51 {
52   return (this->magic == other->magic && this->version._major == other->version._major &&
53           this->object_version._major == other->version._major);
54 };
55