|
38 | 38 | SimpleAllocator allocator_;
|
39 | 39 | NSDictionary* AppPackageJson = nil;
|
40 | 40 |
|
| 41 | +// TODO: consider listening to timezone changes and automatically reseting the DateTime. Probably makes more sense to move it to its own file |
| 42 | +//void UpdateTimezoneNotificationCallback(CFNotificationCenterRef center, |
| 43 | +// void *observer, |
| 44 | +// CFStringRef name, |
| 45 | +// const void *object, |
| 46 | +// CFDictionaryRef userInfo) { |
| 47 | +// Runtime* r = (Runtime*)observer; |
| 48 | +// auto isolate = r->GetIsolate(); |
| 49 | +// |
| 50 | +// CFRunLoopPerformBlock(r->RuntimeLoop(), kCFRunLoopDefaultMode, ^() { |
| 51 | +// TODO: lock isolate here? |
| 52 | +// isolate->DateTimeConfigurationChangeNotification(Isolate::TimeZoneDetection::kRedetect); |
| 53 | +// }); |
| 54 | +//} |
| 55 | +// add this to register (most likely on setting up isolate |
| 56 | +//CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, &UpdateTimezoneNotificationCallback, kCFTimeZoneSystemTimeZoneDidChangeNotification, nullptr, CFNotificationSuspensionBehaviorDeliverImmediately); |
| 57 | +// add this to remove the observer |
| 58 | +//CFNotificationCenterRemoveObserver(CFNotificationCenterGetLocalCenter(), this, kCFTimeZoneSystemTimeZoneDidChangeNotification, NULL); |
| 59 | + |
41 | 60 | void DisposeIsolateWhenPossible(Isolate* isolate) {
|
42 | 61 | // most of the time, this will never delay disposal
|
43 | 62 | // occasionally this can happen when the runtime is destroyed by actions of its own isolate
|
@@ -379,6 +398,13 @@ void DisposeIsolateWhenPossible(Isolate* isolate) {
|
379 | 398 | globalTemplate->Set(ToV8String(isolate, "__drainMicrotaskQueue"), drainMicrotaskTemplate);
|
380 | 399 | }
|
381 | 400 |
|
| 401 | +void Runtime::DefineDateTimeConfigurationChangeNotificationMethod(v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> globalTemplate) { |
| 402 | + Local<FunctionTemplate> drainMicrotaskTemplate = FunctionTemplate::New(isolate, [](const FunctionCallbackInfo<Value>& info) { |
| 403 | + info.GetIsolate()->DateTimeConfigurationChangeNotification(Isolate::TimeZoneDetection::kRedetect); |
| 404 | + }); |
| 405 | + globalTemplate->Set(ToV8String(isolate, "__dateTimeConfigurationChangeNotification"), drainMicrotaskTemplate); |
| 406 | +} |
| 407 | + |
382 | 408 | bool Runtime::IsAlive(const Isolate* isolate) {
|
383 | 409 | // speedup lookup by avoiding locking if thread locals match
|
384 | 410 | // note: this can be a problem when the Runtime is deleted in a different thread that it was created
|
|
0 commit comments