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
e72725b5
Commit
e72725b5
authored
Jul 13, 2012
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new function: to_string(detail::yield_state)
parent
bf30622e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
25 deletions
+26
-25
cppa/detail/yield_interface.hpp
cppa/detail/yield_interface.hpp
+8
-0
src/yield_interface.cpp
src/yield_interface.cpp
+16
-0
unit_testing/test__yield_interface.cpp
unit_testing/test__yield_interface.cpp
+2
-25
No files found.
cppa/detail/yield_interface.hpp
View file @
e72725b5
...
@@ -31,6 +31,8 @@
...
@@ -31,6 +31,8 @@
#ifndef CPPA_YIELD_INTERFACE_HPP
#ifndef CPPA_YIELD_INTERFACE_HPP
#define CPPA_YIELD_INTERFACE_HPP
#define CPPA_YIELD_INTERFACE_HPP
#include <string>
#include "cppa/util/fiber.hpp"
#include "cppa/util/fiber.hpp"
namespace
cppa
{
namespace
detail
{
namespace
cppa
{
namespace
detail
{
...
@@ -54,4 +56,10 @@ yield_state call(util::fiber* what, util::fiber* from);
...
@@ -54,4 +56,10 @@ yield_state call(util::fiber* what, util::fiber* from);
}
}
// namespace cppa::detail
}
}
// namespace cppa::detail
namespace
cppa
{
std
::
string
to_string
(
detail
::
yield_state
ys
);
}
// namespace cppa
#endif // CPPA_YIELD_INTERFACE_HPP
#endif // CPPA_YIELD_INTERFACE_HPP
src/yield_interface.cpp
View file @
e72725b5
...
@@ -40,6 +40,13 @@ __thread detail::yield_state* t_ystate = nullptr;
...
@@ -40,6 +40,13 @@ __thread detail::yield_state* t_ystate = nullptr;
__thread
util
::
fiber
*
t_caller
=
nullptr
;
__thread
util
::
fiber
*
t_caller
=
nullptr
;
__thread
util
::
fiber
*
t_callee
=
nullptr
;
__thread
util
::
fiber
*
t_callee
=
nullptr
;
constexpr
const
char
*
names_table
[]
=
{
"yield_state::invalid"
,
"yield_state::ready"
,
"yield_state::blocked"
,
"yield_state::done"
};
}
// namespace <anonymous>
}
// namespace <anonymous>
namespace
cppa
{
namespace
detail
{
namespace
cppa
{
namespace
detail
{
...
@@ -59,3 +66,12 @@ yield_state call(util::fiber* what, util::fiber* from) {
...
@@ -59,3 +66,12 @@ yield_state call(util::fiber* what, util::fiber* from) {
}
}
}
}
// namespace cppa::detail
}
}
// namespace cppa::detail
namespace
cppa
{
std
::
string
to_string
(
detail
::
yield_state
ys
)
{
auto
i
=
static_cast
<
size_t
>
(
ys
);
return
(
i
<
sizeof
(
names_table
))
?
names_table
[
i
]
:
"{illegal yield_state}"
;
}
}
// namespace cppa
unit_testing/test__yield_interface.cpp
View file @
e72725b5
...
@@ -8,28 +8,6 @@
...
@@ -8,28 +8,6 @@
#include "cppa/util/fiber.hpp"
#include "cppa/util/fiber.hpp"
#include "cppa/detail/yield_interface.hpp"
#include "cppa/detail/yield_interface.hpp"
#include <boost/context/all.hpp>
namespace
cppa
{
namespace
detail
{
std
::
ostream
&
operator
<<
(
std
::
ostream
&
o
,
yield_state
ys
)
{
switch
(
ys
)
{
case
yield_state
:
:
invalid
:
return
(
o
<<
"yield_state::invalid"
);
case
yield_state
:
:
ready
:
return
(
o
<<
"yield_state::ready"
);
case
yield_state
:
:
blocked
:
return
(
o
<<
"yield_state::blocked"
);
case
yield_state
:
:
done
:
return
(
o
<<
"yield_state::done"
);
default:
return
(
o
<<
"{{{invalid yield_state}}}"
);
}
}
}
}
// namespace cppa::detail
using
namespace
cppa
;
using
namespace
cppa
;
using
namespace
cppa
::
util
;
using
namespace
cppa
::
util
;
using
namespace
cppa
::
detail
;
using
namespace
cppa
::
detail
;
...
@@ -55,8 +33,7 @@ struct pseudo_worker {
...
@@ -55,8 +33,7 @@ struct pseudo_worker {
};
};
void
coroutine
(
void
*
worker
)
{
(
*
reinterpret_cast
<
pseudo_worker
*>
(
worker
))();
void
coroutine
(
void
*
worker
)
{
(
*
reinterpret_cast
<
pseudo_worker
*>
(
worker
))();
}
}
size_t
test__yield_interface
()
{
size_t
test__yield_interface
()
{
CPPA_TEST
(
test__yield_interface
);
CPPA_TEST
(
test__yield_interface
);
...
@@ -76,7 +53,7 @@ size_t test__yield_interface() {
...
@@ -76,7 +53,7 @@ size_t test__yield_interface() {
++
i
;
++
i
;
}
}
while
(
ys
!=
yield_state
::
done
&&
i
<
12
);
while
(
ys
!=
yield_state
::
done
&&
i
<
12
);
CPPA_CHECK_EQUAL
(
yield_state
::
done
,
ys
);
CPPA_CHECK_EQUAL
(
"yield_state::done"
,
to_string
(
ys
)
);
CPPA_CHECK_EQUAL
(
10
,
worker
.
m_count
);
CPPA_CHECK_EQUAL
(
10
,
worker
.
m_count
);
CPPA_CHECK_EQUAL
(
12
,
i
);
CPPA_CHECK_EQUAL
(
12
,
i
);
# endif
# endif
...
...
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