2014-06-30 19:39:45 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-09-19 17:54:41 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef MainThreadUtils_h_
|
|
|
|
#define MainThreadUtils_h_
|
|
|
|
|
|
|
|
#include "nscore.h"
|
|
|
|
|
|
|
|
class nsIThread;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a reference to the main thread.
|
|
|
|
*
|
2014-06-27 05:35:39 +04:00
|
|
|
* @param aResult
|
2013-09-19 17:54:41 +04:00
|
|
|
* The resulting nsIThread object.
|
|
|
|
*/
|
2016-08-15 07:29:43 +03:00
|
|
|
extern nsresult NS_GetMainThread(nsIThread** aResult);
|
2013-09-19 17:54:41 +04:00
|
|
|
|
2014-06-07 01:53:42 +04:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
|
|
|
// Fast access to the current thread. Do not release the returned pointer! If
|
|
|
|
// you want to use this pointer from some other thread, then you will need to
|
|
|
|
// AddRef it. Otherwise, you should only consider this pointer valid from code
|
|
|
|
// running on the current thread.
|
2014-08-28 02:47:27 +04:00
|
|
|
extern nsIThread* NS_GetCurrentThread();
|
2014-06-07 01:53:42 +04:00
|
|
|
#endif
|
|
|
|
|
2014-07-04 14:34:15 +04:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
2017-08-30 06:13:50 +03:00
|
|
|
bool NS_IsMainThreadTLSInitialized();
|
2019-02-07 19:14:04 +03:00
|
|
|
extern "C" {
|
2013-09-19 17:54:41 +04:00
|
|
|
bool NS_IsMainThread();
|
2019-02-07 19:14:04 +03:00
|
|
|
}
|
2018-02-05 21:55:07 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
# ifdef DEBUG
|
|
|
|
void AssertIsOnMainThread();
|
|
|
|
# else
|
|
|
|
inline void AssertIsOnMainThread() {}
|
|
|
|
# endif
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2013-09-19 17:54:41 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // MainThreadUtils_h_
|