2014-06-30 08:39:45 -07: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 06:54:41 -07: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"
|
|
|
|
#include "mozilla/threads/nsThreadIDs.h"
|
|
|
|
|
|
|
|
class nsIThread;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a reference to the main thread.
|
|
|
|
*
|
2014-06-26 18:35:39 -07:00
|
|
|
* @param aResult
|
2013-09-19 06:54:41 -07:00
|
|
|
* The resulting nsIThread object.
|
|
|
|
*/
|
2014-08-27 15:47:27 -07:00
|
|
|
extern NS_METHOD NS_GetMainThread(nsIThread** aResult);
|
2013-09-19 06:54:41 -07:00
|
|
|
|
2014-06-06 14:53:42 -07: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-27 15:47:27 -07:00
|
|
|
extern nsIThread* NS_GetCurrentThread();
|
2014-06-06 14:53:42 -07:00
|
|
|
#endif
|
|
|
|
|
2014-07-04 03:34:15 -07:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
2013-09-19 06:54:41 -07:00
|
|
|
bool NS_IsMainThread();
|
|
|
|
#else
|
|
|
|
/**
|
|
|
|
* Test to see if the current thread is the main thread.
|
|
|
|
*
|
|
|
|
* @returns true if the current thread is the main thread, and false
|
|
|
|
* otherwise.
|
|
|
|
*/
|
2014-08-27 15:47:27 -07:00
|
|
|
extern bool NS_IsMainThread();
|
2013-09-19 06:54:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // MainThreadUtils_h_
|