|
@@ -5,11 +5,15 @@ namespace Invercargill {
|
|
|
private static Dictionary<int, NativeElement> cache;
|
|
|
|
|
|
public T once<T>(owned CachedGet<T> constructor) {
|
|
|
+ int location = (int)constructor;
|
|
|
+ return keyed_once<T>(location, (owned)constructor);
|
|
|
+ }
|
|
|
+
|
|
|
+ public T keyed_once<T>(int location, owned CachedGet<T> constructor) {
|
|
|
if(cache == null) {
|
|
|
cache = new Dictionary<int, NativeElement>();
|
|
|
}
|
|
|
|
|
|
- int location = (int)constructor;
|
|
|
NativeElement<T> element;
|
|
|
if(!cache.try_get(location, out element)) {
|
|
|
element = new NativeElement<T>(constructor());
|