-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
820fefb
commit 853950b
Showing
12 changed files
with
171 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// ORffiResultCache.h | ||
// OCRunner | ||
// | ||
// Created by Jiang on 2021/2/2. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "ORCoreFunction.h" | ||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface ORffiResultCache : NSObject | ||
@property (nonatomic, strong)NSMutableDictionary <NSValue *,NSValue *>*cache; | ||
+ (instancetype)shared; | ||
- (void)saveffiResult:(or_ffi_result *)result WithKey:(NSValue *)key; | ||
- (or_ffi_result *)ffiResultForKey:(NSValue *)key; | ||
- (void)removeForKey:(NSValue *)key; | ||
- (void)clear; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// ORffiResultCache.m | ||
// OCRunner | ||
// | ||
// Created by Jiang on 2021/2/2. | ||
// | ||
|
||
#import "ORffiResultCache.h" | ||
|
||
@implementation ORffiResultCache | ||
+ (instancetype)shared{ | ||
static dispatch_once_t onceToken; | ||
static ORffiResultCache *_instance; | ||
dispatch_once(&onceToken, ^{ | ||
_instance = [ORffiResultCache new]; | ||
}); | ||
return _instance; | ||
} | ||
- (instancetype)init | ||
{ | ||
self = [super init]; | ||
if (self) { | ||
self.cache = [NSMutableDictionary dictionary]; | ||
} | ||
return self; | ||
} | ||
- (void)saveffiResult:(or_ffi_result *)result WithKey:(NSValue *)key{ | ||
self.cache[key] = [NSValue valueWithPointer:result]; | ||
} | ||
- (or_ffi_result *)ffiResultForKey:(NSValue *)key{ | ||
return self.cache[key].pointerValue; | ||
} | ||
- (void)removeForKey:(NSValue *)key{ | ||
[self.cache removeObjectForKey:key]; | ||
} | ||
- (void)clear{ | ||
self.cache = [NSMutableDictionary dictionary]; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.