|
34 | 34 | SimpleAllocator allocator_;
|
35 | 35 | NSDictionary* AppPackageJson = nil;
|
36 | 36 |
|
| 37 | +// TODO: consider listening to timezone changes and automatically reseting the DateTime. Probably makes more sense to move it to its own file |
| 38 | +//void UpdateTimezoneNotificationCallback(CFNotificationCenterRef center, |
| 39 | +// void *observer, |
| 40 | +// CFStringRef name, |
| 41 | +// const void *object, |
| 42 | +// CFDictionaryRef userInfo) { |
| 43 | +// Runtime* r = (Runtime*)observer; |
| 44 | +// auto isolate = r->GetIsolate(); |
| 45 | +// |
| 46 | +// CFRunLoopPerformBlock(r->RuntimeLoop(), kCFRunLoopDefaultMode, ^() { |
| 47 | +// TODO: lock isolate here? |
| 48 | +// isolate->DateTimeConfigurationChangeNotification(Isolate::TimeZoneDetection::kRedetect); |
| 49 | +// }); |
| 50 | +//} |
| 51 | +// add this to register (most likely on setting up isolate |
| 52 | +//CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, &UpdateTimezoneNotificationCallback, kCFTimeZoneSystemTimeZoneDidChangeNotification, nullptr, CFNotificationSuspensionBehaviorDeliverImmediately); |
| 53 | +// add this to remove the observer |
| 54 | +//CFNotificationCenterRemoveObserver(CFNotificationCenterGetLocalCenter(), this, kCFTimeZoneSystemTimeZoneDidChangeNotification, NULL); |
| 55 | + |
37 | 56 | void DisposeIsolateWhenPossible(Isolate* isolate) {
|
38 | 57 | // most of the time, this will never delay disposal
|
39 | 58 | // occasionally this can happen when the runtime is destroyed by actions of its own isolate
|
@@ -298,6 +317,13 @@ void DisposeIsolateWhenPossible(Isolate* isolate) {
|
298 | 317 | globalTemplate->Set(ToV8String(isolate, "__drainMicrotaskQueue"), drainMicrotaskTemplate);
|
299 | 318 | }
|
300 | 319 |
|
| 320 | +void Runtime::DefineDateTimeConfigurationChangeNotificationMethod(v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> globalTemplate) { |
| 321 | + Local<FunctionTemplate> drainMicrotaskTemplate = FunctionTemplate::New(isolate, [](const FunctionCallbackInfo<Value>& info) { |
| 322 | + info.GetIsolate()->DateTimeConfigurationChangeNotification(Isolate::TimeZoneDetection::kRedetect); |
| 323 | + }); |
| 324 | + globalTemplate->Set(ToV8String(isolate, "__dateTimeConfigurationChangeNotification"), drainMicrotaskTemplate); |
| 325 | +} |
| 326 | + |
301 | 327 | bool Runtime::IsAlive(const Isolate* isolate) {
|
302 | 328 | SpinLock lock(isolatesMutex_);
|
303 | 329 | return std::find(Runtime::isolates_.begin(), Runtime::isolates_.end(), isolate) != Runtime::isolates_.end();
|
|
0 commit comments