Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
6df54e2d
Commit
6df54e2d
authored
Jan 01, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pth support
parent
3d0421da
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
src/yield_interface.cpp
src/yield_interface.cpp
+0
-1
unit_testing/test__yield_interface.cpp
unit_testing/test__yield_interface.cpp
+16
-8
No files found.
src/yield_interface.cpp
View file @
6df54e2d
...
...
@@ -59,7 +59,6 @@ void call(util::fiber* what, util::fiber* from)
{
t_ystate
=
yield_state
::
invalid
;
t_caller
=
from
;
//t_caller.reset(from);
t_callee
=
what
;
util
::
fiber
::
swap
(
*
from
,
*
what
);
}
...
...
unit_testing/test__yield_interface.cpp
View file @
6df54e2d
...
...
@@ -26,17 +26,25 @@ struct pseudo_worker
{
int
m_count
;
bool
m_blocked
;
pseudo_worker
()
:
m_count
(
0
)
{
}
pseudo_worker
()
:
m_count
(
0
)
,
m_blocked
(
true
)
{
}
void
operator
()()
{
for
(;;)
{
if
(
m_blocked
)
{
yield
(
yield_state
::
blocked
);
}
else
{
++
m_count
;
yield
(
m_count
<
10
?
yield_state
::
ready
:
yield_state
::
done
);
}
}
}
};
...
...
@@ -54,18 +62,18 @@ size_t test__yield_interface()
fiber
fself
;
fiber
fcoroutine
(
coroutine
,
&
worker
);
auto
do_switch
=
[
&
]()
{
call
(
&
fcoroutine
,
&
fself
);
};
int
i
=
0
;
do
{
do_switch
();
if
(
i
==
2
)
worker
.
m_blocked
=
false
;
call
(
&
fcoroutine
,
&
fself
);
++
i
;
}
while
(
yielded_state
()
!=
yield_state
::
done
&&
i
<
1
0
);
while
(
yielded_state
()
!=
yield_state
::
done
&&
i
<
1
2
);
CPPA_CHECK_EQUAL
(
yielded_state
(),
yield_state
::
done
);
CPPA_CHECK_EQUAL
(
i
,
10
);
CPPA_CHECK_EQUAL
(
worker
.
m_count
,
10
);
CPPA_CHECK_EQUAL
(
i
,
12
);
return
CPPA_TEST_RESULT
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment