本文整理汇总了C++中mozilla::ThreadLocal::init方法的典型用法代码示例。如果您正苦于以下问题:C++ ThreadLocal::init方法的具体用法?C++ ThreadLocal::init怎么用?C++ ThreadLocal::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozilla::ThreadLocal
的用法示例。
在下文中一共展示了ThreadLocal::init方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mozilla_sampler_init
void mozilla_sampler_init()
{
if (!tlsStack.init() || !tlsTicker.init()) {
LOG("Failed to init.");
return;
}
stack_key_initialized = true;
ProfileStack *stack = new ProfileStack();
tlsStack.set(stack);
#if defined(USE_LIBUNWIND) && defined(ANDROID)
// Only try debug_frame and exidx unwinding
putenv("UNW_ARM_UNWIND_METHOD=5");
// Allow the profiler to be started and stopped using signals
OS::RegisterStartStopHandlers();
// On Android, this is too soon in order to start up the
// profiler.
return;
#endif
// We can't open pref so we use an environment variable
// to know if we should trigger the profiler on startup
// NOTE: Default
const char *val = PR_GetEnv("MOZ_PROFILER_STARTUP");
if (!val || !*val) {
return;
}
mozilla_sampler_start(PROFILE_DEFAULT_ENTRY, PROFILE_DEFAULT_INTERVAL,
PROFILE_DEFAULT_FEATURES, PROFILE_DEFAULT_FEATURE_COUNT);
}
示例2: SetStaticGLContext
static void SetStaticGLContext(GLContext* context)
{
if (!sGLContext.initialized()) {
mozilla::DebugOnly<bool> success = sGLContext.init();
MOZ_ASSERT(success);
}
sGLContext.set(context);
}
示例3:
void
NS_SetMainThread()
{
if (!sTLSIsMainThread.initialized()) {
if (!sTLSIsMainThread.init()) {
MOZ_CRASH();
}
sTLSIsMainThread.set(true);
}
MOZ_ASSERT(NS_IsMainThread());
}
示例4:
void
InitScriptSettings()
{
if (!sScriptSettingsTLS.initialized()) {
bool success = sScriptSettingsTLS.init();
if (!success) {
MOZ_CRASH();
}
}
sScriptSettingsTLS.set(nullptr);
}
示例5: EnsureGLContext
void EnsureGLContext(const GrGLInterface* i)
{
const DrawTarget* drawTarget = reinterpret_cast<const DrawTarget*>(i->fCallbackData);
GLContext* gl = static_cast<GLContext*>(drawTarget->GetGLContext());
gl->MakeCurrent();
if (!sGLContext.initialized()) {
mozilla::DebugOnly<bool> success = sGLContext.init();
MOZ_ASSERT(success);
}
sGLContext.set(gl);
}
示例6: EnsureGLContext
void EnsureGLContext(const GrGLInterface* i)
{
const SkiaGLGlue* contextSkia = reinterpret_cast<const SkiaGLGlue*>(i->fCallbackData);
GLContext* gl = contextSkia->GetGLContext();
gl->MakeCurrent();
if (!sGLContext.initialized()) {
mozilla::DebugOnly<bool> success = sGLContext.init();
MOZ_ASSERT(success);
}
sGLContext.set(gl);
}
示例7: ScriptSettingsStack
void
InitScriptSettings()
{
if (!sScriptSettingsTLS.initialized()) {
bool success = sScriptSettingsTLS.init();
if (!success) {
MOZ_CRASH();
}
}
ScriptSettingsStack* ptr = new ScriptSettingsStack();
sScriptSettingsTLS.set(ptr);
}
示例8: ObsoleteCurrentTraceInfos
void
InitTaskTracer(uint32_t aFlags)
{
if (aFlags & FORKED_AFTER_NUWA) {
ObsoleteCurrentTraceInfos();
return;
}
MOZ_ASSERT(!sTraceInfos);
sTraceInfos = new nsTArray<nsAutoPtr<TraceInfo>>();
if (!sTraceInfoTLS.initialized()) {
Unused << sTraceInfoTLS.init();
}
}
示例9: mozilla_sampler_init
void mozilla_sampler_init(void* stackTop)
{
sInitCount++;
if (stack_key_initialized)
return;
#ifdef SPS_STANDALONE
mozilla::TimeStamp::Startup();
#endif
LOG("BEGIN mozilla_sampler_init");
if (!tlsPseudoStack.init() || !tlsTicker.init() || !tlsStackTop.init()) {
LOG("Failed to init.");
return;
}
bool ignore;
sStartTime = mozilla::TimeStamp::ProcessCreation(ignore);
stack_key_initialized = true;
Sampler::Startup();
PseudoStack *stack = PseudoStack::create();
tlsPseudoStack.set(stack);
bool isMainThread = true;
Sampler::RegisterCurrentThread(isMainThread ?
gGeckoThreadName : "Application Thread",
stack, isMainThread, stackTop);
// Read interval settings from MOZ_PROFILER_INTERVAL and stack-scan
// threshhold from MOZ_PROFILER_STACK_SCAN.
read_profiler_env_vars();
// platform specific initialization
OS::Startup();
#ifndef SPS_STANDALONE
set_stderr_callback(mozilla_sampler_log);
#endif
// We can't open pref so we use an environment variable
// to know if we should trigger the profiler on startup
// NOTE: Default
const char *val = getenv("MOZ_PROFILER_STARTUP");
if (!val || !*val) {
return;
}
const char* features[] = {"js"
, "leaf"
, "threads"
#if defined(XP_WIN) || defined(XP_MACOSX) \
|| (defined(SPS_ARCH_arm) && defined(linux)) \
|| defined(SPS_PLAT_amd64_linux) || defined(SPS_PLAT_x86_linux)
, "stackwalk"
#endif
#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
, "java"
#endif
};
const char* threadFilters[] = { "GeckoMain", "Compositor" };
profiler_start(PROFILE_DEFAULT_ENTRY, PROFILE_DEFAULT_INTERVAL,
features, MOZ_ARRAY_LENGTH(features),
threadFilters, MOZ_ARRAY_LENGTH(threadFilters));
LOG("END mozilla_sampler_init");
}
示例10: mozilla_sampler_init
void mozilla_sampler_init(void* stackTop)
{
sInitCount++;
if (stack_key_initialized)
return;
LOG("BEGIN mozilla_sampler_init");
if (!tlsPseudoStack.init() || !tlsTicker.init() || !tlsStackTop.init()) {
LOG("Failed to init.");
return;
}
stack_key_initialized = true;
Sampler::Startup();
PseudoStack *stack = new PseudoStack();
tlsPseudoStack.set(stack);
bool isMainThread = true;
#ifdef XP_WIN
// For metrofx, we'll register the main thread once it's created.
isMainThread = !(XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro);
#endif
Sampler::RegisterCurrentThread(isMainThread ?
gGeckoThreadName : "Application Thread",
stack, isMainThread, stackTop);
// Read mode settings from MOZ_PROFILER_MODE and interval
// settings from MOZ_PROFILER_INTERVAL and stack-scan threshhold
// from MOZ_PROFILER_STACK_SCAN.
read_profiler_env_vars();
// platform specific initialization
OS::Startup();
set_stderr_callback(profiler_log);
// We can't open pref so we use an environment variable
// to know if we should trigger the profiler on startup
// NOTE: Default
const char *val = PR_GetEnv("MOZ_PROFILER_STARTUP");
if (!val || !*val) {
return;
}
const char* features[] = {"js"
, "leaf"
#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(SPS_ARCH_arm) && defined(linux))
, "stackwalk"
#endif
#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
, "java"
#endif
};
profiler_start(PROFILE_DEFAULT_ENTRY, PROFILE_DEFAULT_INTERVAL,
features, sizeof(features)/sizeof(const char*),
// TODO Add env variable to select threads
nullptr, 0);
LOG("END mozilla_sampler_init");
}