2015-06-30 19:03:45 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
2017-04-26 21:36:15 +00:00
|
|
|
#ifndef ThreadInfo_h
|
|
|
|
#define ThreadInfo_h
|
2015-06-30 19:03:45 +00:00
|
|
|
|
2017-07-28 19:43:19 +00:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2019-02-07 17:35:37 +00:00
|
|
|
#include "nsISupportsImpl.h"
|
2018-02-17 03:43:51 +00:00
|
|
|
#include "nsString.h"
|
2015-06-30 19:03:45 +00:00
|
|
|
|
2018-02-17 03:43:51 +00:00
|
|
|
// This class contains information about a thread which needs to be stored
|
|
|
|
// across restarts of the profiler and which can be useful even after the
|
|
|
|
// thread has stopped running.
|
|
|
|
// It uses threadsafe refcounting and only contains immutable data.
|
|
|
|
class ThreadInfo final {
|
2017-04-26 21:36:15 +00:00
|
|
|
public:
|
2018-02-17 03:43:51 +00:00
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ThreadInfo)
|
2018-02-18 21:57:55 +00:00
|
|
|
|
2019-06-10 17:35:42 +00:00
|
|
|
ThreadInfo(const char* aName, int aThreadId, bool aIsMainThread,
|
|
|
|
const mozilla::TimeStamp& aRegisterTime =
|
|
|
|
mozilla::TimeStamp::NowUnfuzzed())
|
2018-02-17 03:43:51 +00:00
|
|
|
: mName(aName),
|
2018-05-25 03:34:23 +00:00
|
|
|
mRegisterTime(aRegisterTime),
|
2018-02-17 03:43:51 +00:00
|
|
|
mThreadId(aThreadId),
|
|
|
|
mIsMainThread(aIsMainThread) {
|
|
|
|
// I don't know if we can assert this. But we should warn.
|
|
|
|
MOZ_ASSERT(aThreadId >= 0, "native thread ID is < 0");
|
|
|
|
MOZ_ASSERT(aThreadId <= INT32_MAX, "native thread ID is > INT32_MAX");
|
2018-02-18 21:57:55 +00:00
|
|
|
}
|
|
|
|
|
2018-02-17 03:43:51 +00:00
|
|
|
const char* Name() const { return mName.get(); }
|
|
|
|
mozilla::TimeStamp RegisterTime() const { return mRegisterTime; }
|
2018-01-16 17:07:21 +00:00
|
|
|
int ThreadId() const { return mThreadId; }
|
2018-02-17 03:43:51 +00:00
|
|
|
bool IsMainThread() const { return mIsMainThread; }
|
2018-01-31 22:42:49 +00:00
|
|
|
|
2017-04-26 21:36:15 +00:00
|
|
|
private:
|
2018-02-17 03:43:51 +00:00
|
|
|
~ThreadInfo() {}
|
2017-04-26 21:36:15 +00:00
|
|
|
|
2018-02-17 03:43:51 +00:00
|
|
|
const nsCString mName;
|
|
|
|
const mozilla::TimeStamp mRegisterTime;
|
2018-01-16 17:07:21 +00:00
|
|
|
const int mThreadId;
|
2015-06-30 19:03:45 +00:00
|
|
|
const bool mIsMainThread;
|
|
|
|
};
|
|
|
|
|
2017-04-26 21:36:15 +00:00
|
|
|
#endif // ThreadInfo_h
|