diff options
author | Muxi Yan <mxyan@google.com> | 2016-10-22 12:00:37 -0700 |
---|---|---|
committer | Muxi Yan <mxyan@google.com> | 2016-10-22 12:00:37 -0700 |
commit | ad93106da012bcd2080d229ab5b6c61dd2f59fed (patch) | |
tree | 51795cc660b40c8df9c60c9ae8caeb98eeedfa92 /src/objective-c/GRPCClient/private | |
parent | 6ac6a52dcf4f4fbc01d88832e5e1559fd94f8921 (diff) |
Keep a singleton of connectivity monitor in GRPCHost
Diffstat (limited to 'src/objective-c/GRPCClient/private')
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCHost.m | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m index 9d7b3a7f0b..7031e01eb1 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -100,19 +100,16 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil; _address = address; _secure = YES; kHostCache[address] = self; - - // When there is host in the cache, keep a single monitor to the network - // to - // flush the cache if the connectivity status changed - if (!connectivityMonitor) { - connectivityMonitor = - [GRPCConnectivityMonitor monitorWithHost:hostURL.host]; - void (^handler)() = ^{ - [GRPCHost flushChannelCache]; - }; - [connectivityMonitor handleLossWithHandler:handler - wifiStatusChangeHandler:handler]; - } + } + // Keep a single monitor to flush the cache if the connectivity status changed + if (!connectivityMonitor) { + connectivityMonitor = + [GRPCConnectivityMonitor monitorWithHost:hostURL.host]; + void (^handler)() = ^{ + [GRPCHost flushChannelCache]; + }; + [connectivityMonitor handleLossWithHandler:handler + wifiStatusChangeHandler:handler]; } } return self; @@ -125,8 +122,6 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil; BOOL * _Nonnull stop) { [host disconnect]; }]; - [kHostCache removeAllObjects]; - connectivityMonitor = nil; } } |