netwerk/cache/nsCacheUtils.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/cache/nsCacheUtils.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,44 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* vim: set sw=2 ts=8 et tw=80 : */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef _nsCacheUtils_h_
    1.11 +#define _nsCacheUtils_h_
    1.12 +
    1.13 +#include "nsThreadUtils.h"
    1.14 +#include "nsCOMPtr.h"
    1.15 +#include "mozilla/Mutex.h"
    1.16 +#include "mozilla/CondVar.h"
    1.17 +
    1.18 +class nsIThread;
    1.19 +
    1.20 +/**
    1.21 + * A class with utility methods for shutting down nsIThreads easily.
    1.22 +  */
    1.23 +class nsShutdownThread : public nsRunnable {
    1.24 +public:
    1.25 +  nsShutdownThread(nsIThread *aThread);
    1.26 +  ~nsShutdownThread();
    1.27 +
    1.28 +  NS_IMETHOD Run();
    1.29 +
    1.30 +/**
    1.31 + * Shutdown ensures that aThread->Shutdown() is called on a main thread
    1.32 + */
    1.33 +  static nsresult Shutdown(nsIThread *aThread);
    1.34 +
    1.35 +/**
    1.36 + * BlockingShutdown ensures that by the time it returns, aThread->Shutdown() has
    1.37 + * been called and no pending events have been processed on the current thread.
    1.38 + */
    1.39 +  static nsresult BlockingShutdown(nsIThread *aThread);
    1.40 +
    1.41 +private:
    1.42 +  mozilla::Mutex      mLock;
    1.43 +  mozilla::CondVar    mCondVar;
    1.44 +  nsCOMPtr<nsIThread> mThread;
    1.45 +};
    1.46 +
    1.47 +#endif

mercurial