mobile/android/base/sync/net/ConnectionMonitorThread.java

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 package org.mozilla.gecko.sync.net;
     7 import org.mozilla.gecko.background.common.log.Logger;
     9 /**
    10  * Every <code>REAP_INTERVAL</code> milliseconds, wake up
    11  * and expire any connections that need cleaning up.
    12  *
    13  * When we're told to shut down, take the connection manager
    14  * with us.
    15  */
    16 public class ConnectionMonitorThread extends Thread {
    17   private static final long REAP_INTERVAL = 5000;     // 5 seconds.
    18   private static final String LOG_TAG = "ConnectionMonitorThread";
    20   private volatile boolean stopping;
    22   @Override
    23   public void run() {
    24     try {
    25       while (!stopping) {
    26         synchronized (this) {
    27           wait(REAP_INTERVAL);
    28           BaseResource.closeExpiredConnections();
    29         }
    30       }
    31     } catch (InterruptedException e) {
    32       Logger.trace(LOG_TAG, "Interrupted.");
    33     }
    34     BaseResource.shutdownConnectionManager();
    35   }
    37   public void shutdown() {
    38     Logger.debug(LOG_TAG, "ConnectionMonitorThread told to shut down.");
    39     stopping = true;
    40     synchronized (this) {
    41       notifyAll();
    42     }
    43   }
    44 }

mercurial