Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
7f16789b
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7f16789b
编写于
3月 05, 2019
作者:
C
Chinmay Garde
提交者:
GitHub
3月 05, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove redundant thread checker in FML. (#8053)
There is already fml/memory/thread_checker.h
上级
840c5233
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
0 addition
and
112 deletion
+0
-112
ci/licenses_golden/licenses_flutter
ci/licenses_golden/licenses_flutter
+0
-2
fml/BUILD.gn
fml/BUILD.gn
+0
-2
fml/synchronization/thread_checker.h
fml/synchronization/thread_checker.h
+0
-71
fml/synchronization/thread_checker_unittest.cc
fml/synchronization/thread_checker_unittest.cc
+0
-37
未找到文件。
ci/licenses_golden/licenses_flutter
浏览文件 @
7f16789b
...
...
@@ -219,8 +219,6 @@ FILE: ../../../flutter/fml/synchronization/shared_mutex_std.cc
FILE: ../../../flutter/fml/synchronization/shared_mutex_std.h
FILE: ../../../flutter/fml/synchronization/thread_annotations.h
FILE: ../../../flutter/fml/synchronization/thread_annotations_unittest.cc
FILE: ../../../flutter/fml/synchronization/thread_checker.h
FILE: ../../../flutter/fml/synchronization/thread_checker_unittest.cc
FILE: ../../../flutter/fml/synchronization/waitable_event.cc
FILE: ../../../flutter/fml/synchronization/waitable_event.h
FILE: ../../../flutter/fml/synchronization/waitable_event_unittest.cc
...
...
fml/BUILD.gn
浏览文件 @
7f16789b
...
...
@@ -50,7 +50,6 @@ source_set("fml") {
"synchronization/count_down_latch.h",
"synchronization/shared_mutex.h",
"synchronization/thread_annotations.h",
"synchronization/thread_checker.h",
"synchronization/waitable_event.cc",
"synchronization/waitable_event.h",
"task_runner.cc",
...
...
@@ -188,7 +187,6 @@ executable("fml_unittests") {
"string_view_unittest.cc",
"synchronization/count_down_latch_unittests.cc",
"synchronization/thread_annotations_unittest.cc",
"synchronization/thread_checker_unittest.cc",
"synchronization/waitable_event_unittest.cc",
"thread_local_unittests.cc",
"thread_unittests.cc",
...
...
fml/synchronization/thread_checker.h
已删除
100644 → 0
浏览文件 @
840c5233
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// A class for checking that the current thread is/isn't the same as an initial
// thread.
#ifndef FLUTTER_FML_SYNCHRONIZATION_THREAD_CHECKER_H_
#define FLUTTER_FML_SYNCHRONIZATION_THREAD_CHECKER_H_
#include "flutter/fml/build_config.h"
#if defined(OS_WIN)
#include <windows.h>
#else
#include <pthread.h>
#endif
#include "flutter/fml/logging.h"
#include "flutter/fml/macros.h"
namespace
fml
{
// A simple class that records the identity of the thread that it was created
// on, and at later points can tell if the current thread is the same as its
// creation thread. This class is thread-safe.
//
// Note: Unlike Chromium's |base::ThreadChecker|, this is *not* Debug-only (so
// #ifdef it out if you want something Debug-only). (Rationale: Having a
// |CalledOnValidThread()| that lies in Release builds seems bad. Moreover,
// there's a small space cost to having even an empty class. )
class
ThreadChecker
final
{
public:
#if defined(OS_WIN)
ThreadChecker
()
:
self_
(
GetCurrentThreadId
())
{}
~
ThreadChecker
()
{}
bool
IsCreationThreadCurrent
()
const
{
return
GetCurrentThreadId
()
==
self_
;
}
private:
const
DWORD
self_
;
#else
ThreadChecker
()
:
self_
(
pthread_self
())
{}
~
ThreadChecker
()
{}
// Returns true if the current thread is the thread this object was created
// on and false otherwise.
bool
IsCreationThreadCurrent
()
const
{
return
!!
pthread_equal
(
pthread_self
(),
self_
);
}
private:
const
pthread_t
self_
;
#endif
FML_DISALLOW_COPY_AND_ASSIGN
(
ThreadChecker
);
};
#ifndef NDEBUG
#define FML_DECLARE_THREAD_CHECKER(c) fml::ThreadChecker c
#define FML_DCHECK_CREATION_THREAD_IS_CURRENT(c) \
FML_DCHECK((c).IsCreationThreadCurrent())
#else
#define FML_DECLARE_THREAD_CHECKER(c)
#define FML_DCHECK_CREATION_THREAD_IS_CURRENT(c) ((void)0)
#endif
}
// namespace fml
#endif // FLUTTER_FML_SYNCHRONIZATION_THREAD_CHECKER_H_
fml/synchronization/thread_checker_unittest.cc
已删除
100644 → 0
浏览文件 @
840c5233
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/fml/synchronization/thread_checker.h"
#include <thread>
#include "gtest/gtest.h"
namespace
fml
{
namespace
{
TEST
(
ThreadCheckerTest
,
SameThread
)
{
ThreadChecker
checker
;
EXPECT_TRUE
(
checker
.
IsCreationThreadCurrent
());
}
// Note: This test depends on |std::thread| being compatible with
// |pthread_self()|.
TEST
(
ThreadCheckerTest
,
DifferentThreads
)
{
ThreadChecker
checker1
;
EXPECT_TRUE
(
checker1
.
IsCreationThreadCurrent
());
std
::
thread
thread
([
&
checker1
]()
{
ThreadChecker
checker2
;
EXPECT_TRUE
(
checker2
.
IsCreationThreadCurrent
());
EXPECT_FALSE
(
checker1
.
IsCreationThreadCurrent
());
});
thread
.
join
();
// Note: Without synchronization, we can't look at |checker2| from the main
// thread.
}
}
// namespace
}
// namespace fml
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录