Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
study
提交
f47fefa2
S
study
项目概览
OpenDocCN
/
study
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
study
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f47fefa2
编写于
7月 01, 2019
作者:
C
codinghuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
complete the create coroutine
上级
167a891d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
6 addition
and
8 deletion
+6
-8
include/asm_context.h
include/asm_context.h
+2
-2
include/context.h
include/context.h
+0
-1
include/coroutine.h
include/coroutine.h
+2
-0
src/coroutine/context.cc
src/coroutine/context.cc
+1
-5
src/coroutine/coroutine.cc
src/coroutine/coroutine.cc
+1
-0
未找到文件。
include/asm_context.h
浏览文件 @
f47fefa2
...
...
@@ -5,7 +5,7 @@
typedef
void
*
fcontext_t
;
intptr_t
jump_fcontext
(
fcontext_t
*
ofc
,
fcontext_t
nfc
,
intptr_t
vp
,
bool
preserve_fpu
=
false
);
fcontext_t
make_fcontext
(
void
*
sp
,
size_t
size
,
void
(
*
fn
)(
intptr_t
)
);
extern
intptr_t
jump_fcontext
(
fcontext_t
*
ofc
,
fcontext_t
nfc
,
intptr_t
vp
,
bool
preserve_fpu
=
false
)
asm
(
"jump_fcontext"
);
extern
fcontext_t
make_fcontext
(
void
*
sp
,
size_t
size
,
void
(
*
fn
)(
intptr_t
))
asm
(
"make_fcontext"
);
#endif
/* ASM_CONTEXT_H */
\ No newline at end of file
include/context.h
浏览文件 @
f47fefa2
...
...
@@ -12,7 +12,6 @@ class Context
{
public:
Context
(
size_t
stack_size
,
coroutine_func_t
fn
,
void
*
private_data
);
~
Context
();
bool
swap_in
();
bool
swap_out
();
static
void
context_func
(
void
*
arg
);
// coroutine entry function
...
...
include/coroutine.h
浏览文件 @
f47fefa2
...
...
@@ -4,6 +4,8 @@
#include "context.h"
#include <unordered_map>
#define DEFAULT_C_STACK_SIZE (2 *1024 * 1024)
namespace
Study
{
class
Coroutine
...
...
src/coroutine/context.cc
浏览文件 @
f47fefa2
#include "context.h"
#include "study.h"
using
Study
::
Context
;
using
namespace
Study
;
Context
::
Context
(
size_t
stack_size
,
coroutine_func_t
fn
,
void
*
private_data
)
:
fn_
(
fn
),
stack_size_
(
stack_size
),
private_data_
(
private_data
)
{
#ifdef SW_CONTEXT_PROTECT_STACK_PAGE
protect_page_
=
0
;
#endif
end_
=
false
;
swap_ctx_
=
nullptr
;
...
...
src/coroutine/coroutine.cc
浏览文件 @
f47fefa2
...
...
@@ -5,6 +5,7 @@ using Study::Coroutine;
Coroutine
*
Coroutine
::
current
=
nullptr
;
long
Coroutine
::
last_cid
=
0
;
std
::
unordered_map
<
long
,
Coroutine
*>
Coroutine
::
coroutines
;
size_t
Coroutine
::
stack_size
=
DEFAULT_C_STACK_SIZE
;
void
*
Coroutine
::
get_current_task
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录