Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
沉迷打码的小凳子
glide
提交
a1cd3afc
G
glide
项目概览
沉迷打码的小凳子
/
glide
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
glide
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a1cd3afc
编写于
9月 22, 2017
作者:
S
Stéphane Nicolas
提交者:
Sam
9月 22, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
issue #2403: create a UncaughtThrowableStrategy API (#2411)
上级
6fb87b35
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
12 deletion
+51
-12
library/src/main/java/com/bumptech/glide/load/engine/executor/GlideExecutor.java
...om/bumptech/glide/load/engine/executor/GlideExecutor.java
+51
-12
未找到文件。
library/src/main/java/com/bumptech/glide/load/engine/executor/GlideExecutor.java
浏览文件 @
a1cd3afc
...
...
@@ -71,6 +71,24 @@ public final class GlideExecutor extends ThreadPoolExecutor {
DEFAULT_DISK_CACHE_EXECUTOR_NAME
,
UncaughtThrowableStrategy
.
DEFAULT
);
}
/**
* Returns a new fixed thread pool with the default thread count returned from
* {@link #calculateBestThreadCount()}, the {@link #DEFAULT_DISK_CACHE_EXECUTOR_NAME} thread name
* prefix, and a custom
* {@link com.bumptech.glide.load.engine.executor.GlideExecutor.UncaughtThrowableStrategy}
* uncaught throwable strategy.
*
* <p>Disk cache executors do not allow network operations on their threads.
* @param uncaughtThrowableStrategy The {@link
* com.bumptech.glide.load.engine.executor.GlideExecutor.UncaughtThrowableStrategy} to use to
* handle uncaught exceptions.
*/
public
static
GlideExecutor
newDiskCacheExecutor
(
UncaughtThrowableStrategy
uncaughtThrowableStrategy
)
{
return
newDiskCacheExecutor
(
DEFAULT_DISK_CACHE_EXECUTOR_THREADS
,
DEFAULT_DISK_CACHE_EXECUTOR_NAME
,
uncaughtThrowableStrategy
);
}
/**
* Returns a new fixed thread pool with the given thread count, thread name prefix,
* and {@link com.bumptech.glide.load.engine.executor.GlideExecutor.UncaughtThrowableStrategy}.
...
...
@@ -103,6 +121,25 @@ public final class GlideExecutor extends ThreadPoolExecutor {
UncaughtThrowableStrategy
.
DEFAULT
);
}
/**
* Returns a new fixed thread pool with the default thread count returned from
* {@link #calculateBestThreadCount()}, the {@link #DEFAULT_SOURCE_EXECUTOR_NAME} thread name
* prefix, and a custom
* {@link com.bumptech.glide.load.engine.executor.GlideExecutor.UncaughtThrowableStrategy}
* uncaught throwable strategy.
*
* <p>Source executors allow network operations on their threads.
*
* @param uncaughtThrowableStrategy The {@link
* com.bumptech.glide.load.engine.executor.GlideExecutor.UncaughtThrowableStrategy} to use to
* handle uncaught exceptions.
*/
public
static
GlideExecutor
newSourceExecutor
(
UncaughtThrowableStrategy
uncaughtThrowableStrategy
)
{
return
newDiskCacheExecutor
(
DEFAULT_DISK_CACHE_EXECUTOR_THREADS
,
DEFAULT_DISK_CACHE_EXECUTOR_NAME
,
uncaughtThrowableStrategy
);
}
/**
* Returns a new fixed thread pool with the given thread count, thread name prefix,
* and {@link com.bumptech.glide.load.engine.executor.GlideExecutor.UncaughtThrowableStrategy}.
...
...
@@ -274,29 +311,33 @@ public final class GlideExecutor extends ThreadPoolExecutor {
* A strategy for handling unexpected and uncaught {@link Throwable}s thrown by futures run on the
* pool.
*/
public
enum
UncaughtThrowableStrategy
{
public
interface
UncaughtThrowableStrategy
{
/**
* Silently catches and ignores the uncaught {@link Throwable}s.
*/
IGNORE
,
UncaughtThrowableStrategy
IGNORE
=
new
UncaughtThrowableStrategy
()
{
@Override
public
void
handle
(
Throwable
t
)
{
//ignore
}
};
/**
* Logs the uncaught {@link Throwable}s using {@link #TAG} and {@link Log}.
*/
LOG
{
UncaughtThrowableStrategy
LOG
=
new
UncaughtThrowableStrategy
()
{
@Override
p
rotected
void
handle
(
Throwable
t
)
{
p
ublic
void
handle
(
Throwable
t
)
{
if
(
t
!=
null
&&
Log
.
isLoggable
(
TAG
,
Log
.
ERROR
))
{
Log
.
e
(
TAG
,
"Request threw uncaught throwable"
,
t
);
}
}
}
,
}
;
/**
* Rethrows the uncaught {@link Throwable}s to crash the app.
*/
THROW
{
UncaughtThrowableStrategy
THROW
=
new
UncaughtThrowableStrategy
()
{
@Override
protected
void
handle
(
Throwable
t
)
{
super
.
handle
(
t
);
public
void
handle
(
Throwable
t
)
{
if
(
t
!=
null
)
{
throw
new
RuntimeException
(
"Request threw uncaught throwable"
,
t
);
}
...
...
@@ -304,11 +345,9 @@ public final class GlideExecutor extends ThreadPoolExecutor {
};
/** The default strategy, currently {@link #LOG}. */
public
static
final
UncaughtThrowableStrategy
DEFAULT
=
LOG
;
UncaughtThrowableStrategy
DEFAULT
=
LOG
;
protected
void
handle
(
Throwable
t
)
{
// Ignore.
}
void
handle
(
Throwable
t
);
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录