-
Notifications
You must be signed in to change notification settings - Fork 933
/
FICImageTableEntry.h
124 lines (93 loc) · 3.49 KB
/
FICImageTableEntry.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//
// FICImageTableEntry.h
// FastImageCache
//
// Copyright (c) 2013 Path, Inc.
// See LICENSE for full license agreement.
//
#import "FICImports.h"
@class FICImageTableChunk;
@class FICImageCache;
typedef struct {
CFUUIDBytes _entityUUIDBytes;
CFUUIDBytes _sourceImageUUIDBytes;
} FICImageTableEntryMetadata;
/**
`FICImageTableEntry` represents an entry in an image table. It contains the necessary data and metadata to store a single entry of image data. Entries are created from instances of
`<FICImageTableChunk>`.
*/
@interface FICImageTableEntry : NSObject
///---------------------------------------------
/// @name Accessing Image Table Entry Properties
///---------------------------------------------
/**
The length, in bytes, of the entry data.
@discussion Entries begin with the image data, followed by the metadata struct.
*/
@property (nonatomic, assign, readonly) size_t length;
/**
The length, in bytes, of just the image data.
*/
@property (nonatomic, assign, readonly) size_t imageLength;
/**
The bytes that represent the entry data.
*/
@property (nonatomic, assign, readonly) void *bytes;
/**
The entity UUID, in byte form, associated with the entry.
*/
@property (nonatomic, assign) CFUUIDBytes entityUUIDBytes;
/**
The source image UUID, in byte form, associated with the entry.
*/
@property (nonatomic, assign) CFUUIDBytes sourceImageUUIDBytes;
/**
The image table chunk that contains this entry.
*/
@property (nonatomic, readonly) FICImageTableChunk *imageTableChunk;
/**
A weak reference to the image cache that contains the image table chunk that contains this entry.
*/
@property (nonatomic, weak) FICImageCache *imageCache;
/**
The index where this entry exists in the image table.
*/
@property (nonatomic, assign) NSInteger index;
///----------------------------------
/// @name Image Table Entry Lifecycle
///----------------------------------
/**
Initializes a new image table entry from an image table chunk.
@param imageTableChunk The image table chunk that contains the entry data.
@param bytes The bytes from the chunk that contain the entry data.
@param length The length, in bytes, of the entry data.
@return A new image table entry.
*/
- (instancetype)initWithImageTableChunk:(FICImageTableChunk *)imageTableChunk bytes:(void *)bytes length:(size_t)length;
/**
Adds a block to be executed when this image table entry is deallocated.
@param block A block that will be called when this image table entry is deallocated.
@note Because of the highly-concurrent nature of Fast Image Cache, image tables must know when any of their entries are about to be deallocated to disassociate them with its internal data structures.
*/
- (void)executeBlockOnDealloc:(dispatch_block_t)block;
/**
Forces the kernel to page in the memory-mapped, on-disk data backing this entry right away.
*/
- (void)preheat;
///--------------------------------------------
/// @name Flushing a Modified Image Table Entry
///--------------------------------------------
/**
Writes a modified image table entry back to disk.
*/
- (void)flush;
///--------------------------------------------
/// @name Versioning Image Table Entry Metadata
///--------------------------------------------
/**
Returns the current metadata version for image table entries.
@return The integer version number of the current metadata version.
@discussion Whenever the `<FICImageTableEntryMetadata>` struct is changed in any way, the metadata version must be changed.
*/
+ (NSInteger)metadataVersion;
@end