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
1620b8ab
Commit
1620b8ab
authored
Mar 11, 2011
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
local group tests
parent
7893d7a1
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
107 additions
and
46 deletions
+107
-46
cppa/detail/actor_private.hpp
cppa/detail/actor_private.hpp
+2
-1
cppa/intrusive_ptr.hpp
cppa/intrusive_ptr.hpp
+15
-25
cppa/invoke_rules.hpp
cppa/invoke_rules.hpp
+5
-0
cppa/match.hpp
cppa/match.hpp
+13
-0
cppa/message.hpp
cppa/message.hpp
+0
-4
cppa/utype.hpp
cppa/utype.hpp
+13
-1
libcppa.Makefile
libcppa.Makefile
+4
-4
src/mock_scheduler.cpp
src/mock_scheduler.cpp
+3
-3
unit_testing/Makefile
unit_testing/Makefile
+6
-4
unit_testing/test__local_group.cpp
unit_testing/test__local_group.cpp
+46
-4
No files found.
cppa/detail/actor_private.hpp
View file @
1620b8ab
...
...
@@ -38,7 +38,8 @@ inline void receive(invoke_rules& rules)
inline
void
receive
(
invoke_rules
&&
rules
)
{
this_actor
()
->
receive
(
rules
);
invoke_rules
tmp
(
std
::
move
(
rules
));
this_actor
()
->
receive
(
tmp
);
}
inline
const
message
&
last_dequeued
()
...
...
cppa/intrusive_ptr.hpp
View file @
1620b8ab
...
...
@@ -10,7 +10,8 @@
namespace
cppa
{
template
<
typename
T
>
class
intrusive_ptr
:
detail
::
comparable
<
intrusive_ptr
<
T
>
,
T
*>
class
intrusive_ptr
:
detail
::
comparable
<
intrusive_ptr
<
T
>
,
T
*>
,
detail
::
comparable
<
intrusive_ptr
<
T
>>
{
T
*
m_ptr
;
...
...
@@ -105,35 +106,24 @@ class intrusive_ptr : detail::comparable<intrusive_ptr<T>, T*>
return
get
()
==
ptr
;
}
template
<
typename
Y
>
inline
bool
equal_to
(
const
Y
*
ptr
)
const
{
return
get
()
==
ptr
;
}
inline
bool
operator
==
(
const
intrusive_ptr
&
other
)
const
{
return
equal_to
(
other
.
get
());
}
template
<
typename
Y
>
inline
bool
operator
==
(
const
intrusive_ptr
<
Y
>&
other
)
const
inline
bool
equal_to
(
const
intrusive_ptr
&
other
)
const
{
return
equal_to
(
other
.
get
()
);
return
get
()
==
other
.
get
(
);
}
inline
bool
operator
!=
(
const
intrusive_ptr
&
other
)
const
{
return
!
(
*
this
==
other
);
}
};
template
<
typename
Y
>
inline
bool
operator
!=
(
const
intrusive_ptr
<
Y
>&
other
)
const
{
return
!
(
*
this
==
other
);
}
template
<
typename
X
,
typename
Y
>
bool
operator
==
(
const
intrusive_ptr
<
X
>&
lhs
,
const
intrusive_ptr
<
Y
>&
rhs
)
{
return
lhs
.
get
()
==
rhs
.
get
(
);
}
};
template
<
typename
X
,
typename
Y
>
bool
operator
!=
(
const
intrusive_ptr
<
X
>&
lhs
,
const
intrusive_ptr
<
Y
>&
rhs
)
{
return
lhs
.
get
()
!=
rhs
.
get
();
}
}
// namespace cppa
...
...
cppa/invoke_rules.hpp
View file @
1620b8ab
...
...
@@ -20,6 +20,11 @@ struct invoke_rules
invoke_rules
()
{
}
invoke_rules
(
invoke_rules
&&
other
)
:
m_list
(
std
::
move
(
other
.
m_list
))
{
other
.
m_list
.
clear
();
}
invoke_rules
(
intrusive_ptr
<
detail
::
invokable
>&&
arg
)
{
if
(
arg
)
m_list
.
push_back
(
arg
);
...
...
cppa/match.hpp
View file @
1620b8ab
...
...
@@ -80,6 +80,19 @@ get_view(const Tuple<TupleTypes...>& t)
throw
std
::
runtime_error
(
"matcher did not return a valid mapping"
);
}
template
<
typename
...
MatchRules
>
typename
tuple_view_type_from_type_list
<
typename
util
::
filter_type_list
<
any_type
,
util
::
type_list
<
MatchRules
...
>>::
type
>::
type
get_view
(
const
untyped_tuple
&
t
)
{
std
::
vector
<
std
::
size_t
>
mappings
;
if
(
match
<
MatchRules
...
>
(
t
,
mappings
))
{
return
{
t
.
vals
(),
std
::
move
(
mappings
)
};
}
// todo: throw nicer exception
throw
std
::
runtime_error
(
"doesn't match"
);
}
}
// namespace cppa
#endif // MATCH_HPP
cppa/message.hpp
View file @
1620b8ab
...
...
@@ -26,10 +26,6 @@ class message
:
sender
(
s
),
receiver
(
r
),
data
(
ut
)
{
}
content
(
const
actor
&
s
,
const
message_receiver
&
r
,
untyped_tuple
&&
ut
)
:
sender
(
s
),
receiver
(
r
),
data
(
ut
)
{
}
};
private:
...
...
cppa/utype.hpp
View file @
1620b8ab
...
...
@@ -5,13 +5,15 @@
#include <typeinfo>
#include "cppa/object.hpp"
#include "cppa/detail/comparable.hpp"
namespace
cppa
{
/**
* @brief Uniform type information.
*/
struct
utype
struct
utype
:
detail
::
comparable
<
utype
>
,
detail
::
comparable
<
utype
,
std
::
type_info
>
{
/**
...
...
@@ -30,6 +32,16 @@ struct utype
*/
virtual
const
std
::
type_info
&
native
()
const
=
0
;
inline
bool
equal_to
(
const
std
::
type_info
&
what
)
const
{
return
native
()
==
what
;
}
inline
bool
equal_to
(
const
utype
&
what
)
const
{
return
native
()
==
what
.
native
();
}
};
}
// namespace cppa
...
...
libcppa.Makefile
View file @
1620b8ab
CXX = /opt/local/bin/g++-mp-4.5
#CXXFLAGS = -std=c++0x -pedantic -Wall -Wextra -g -O0 -I/opt/local/include/
CXXFLAGS = -std=c++0x -pedantic -Wall -Wextra -O2 -I/opt/local/include/ -fPIC
LIBS = -L/opt/local/lib -lboost_thread-mt
include Makefile.rules
INCLUDES = -I./
#CXXFLAGS = -std=c++0x -pedantic -Wall -Wextra -O2 -I/opt/local/include/ -fPIC
HEADERS = cppa/actor.hpp \
cppa/any_type.hpp \
cppa/config.hpp \
...
...
src/mock_scheduler.cpp
View file @
1620b8ab
...
...
@@ -51,8 +51,8 @@ struct actor_impl : cppa::detail::actor_private
virtual
void
receive
(
cppa
::
invoke_rules
&
rules
)
{
cppa
::
util
::
singly_linked_list
<
actor_message
>
buffer
;
actor_message
*
amsg
=
mailbox
.
pop
();
cppa
::
util
::
singly_linked_list
<
actor_message
>
buffer
;
cppa
::
intrusive_ptr
<
cppa
::
detail
::
intermediate
>
imd
;
while
(
!
(
imd
=
rules
.
get_intermediate
(
amsg
->
msg
.
data
())))
{
...
...
@@ -60,9 +60,9 @@ struct actor_impl : cppa::detail::actor_private
amsg
=
mailbox
.
pop
();
}
m_last_dequeued
=
amsg
->
msg
;
delete
amsg
;
if
(
!
buffer
.
empty
())
mailbox
.
prepend
(
std
::
move
(
buffer
))
;
imd
->
invoke
();
mailbox
.
prepend
(
std
::
move
(
buffer
))
;
delete
amsg
;
}
virtual
void
send
(
cppa
::
detail
::
channel
*
whom
,
...
...
unit_testing/Makefile
View file @
1620b8ab
CXX
=
/opt/local/bin/g++-mp-4.5
include
../Makefile.rules
#CXX = /opt/local/bin/g++-mp-4.5
#CXX = /opt/local/bin/g++-mp-4.6
#CXXFLAGS = -std=c++0x -pedantic -Wall -Wextra -g -O0 -I/opt/local/include/
CXXFLAGS
=
-std
=
c++0x
-pedantic
-Wall
-Wextra
-O2
-I
/opt/local/include/
LIBS
=
-L
/opt/local/lib
-lboost_thread-mt
-L
../
-lcppa
#
CXXFLAGS = -std=c++0x -pedantic -Wall -Wextra -O2 -I/opt/local/include/
#
LIBS = -L/opt/local/lib -lboost_thread-mt -L../ -lcppa
INCLUDES
=
-I
./
-I
../
EXECUTABLE
=
../test
...
...
@@ -28,7 +30,7 @@ OBJECTS = $(SOURCES:.cpp=.o)
$(CXX)
$(CXXFLAGS)
$(INCLUDES)
-c
$<
-o
$@
$(EXECUTABLE)
:
$(OBJECTS) $(HEADERS)
$(CXX)
$(LIBS)
-L
./
-lcppa
$(OBJECTS)
-o
$(EXECUTABLE)
$(CXX)
$(LIBS)
-L
.
.
/
-lcppa
$(OBJECTS)
-o
$(EXECUTABLE)
all
:
$(EXECUTABLE)
...
...
unit_testing/test__local_group.cpp
View file @
1620b8ab
...
...
@@ -133,6 +133,32 @@ struct
}
local
;
struct
storage
{
std
::
map
<
std
::
string
,
intrusive_ptr
<
object
>>
m_map
;
public:
template
<
typename
T
>
T
&
get
(
const
std
::
string
&
key
)
{
const
utype
&
uti
=
uniform_type_info
<
T
>
();
auto
i
=
m_map
.
find
(
key
);
if
(
i
==
m_map
.
end
())
{
i
=
m_map
.
insert
(
std
::
make_pair
(
key
,
uti
.
create
())).
first
;
}
else
if
(
uti
!=
i
->
second
->
type
())
{
// todo: throw nicer exception
throw
std
::
runtime_error
(
"invalid type"
);
}
return
*
reinterpret_cast
<
T
*>
(
i
->
second
->
mutable_value
());
}
};
void
foo_actor
()
{
auto
x
=
(
local
/
"foobar"
)
->
subscribe
(
this_actor
());
...
...
@@ -149,6 +175,19 @@ std::size_t test__local_group()
CPPA_TEST
(
test__local_group
);
/*
storage st;
st.get<int>("foobaz") = 42;
CPPA_CHECK_EQUAL(st.get<int>("foobaz"), 42);
st.get<std::string>("_s") = "Hello World!";
CPPA_CHECK_EQUAL(st.get<std::string>("_s"), "Hello World!");
*/
auto
g
=
local
/
"foobar"
;
for
(
int
i
=
0
;
i
<
5
;
++
i
)
...
...
@@ -158,17 +197,20 @@ std::size_t test__local_group()
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
receive
(
on
<
float
>
()
>>
[
&
]()
{
});
receive
(
on
<
float
>
()
>>
[]()
{
});
}
g
->
send
(
1
);
int
result
=
0
;
auto
rule
=
on
<
int
>
()
>>
[
&
result
](
int
x
)
{
result
+=
x
;
};
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
receive
(
on
<
int
>
()
>>
[
&
](
int
x
)
{
result
+=
x
;
});
receive
(
rule
);
}
CPPA_CHECK_EQUAL
(
result
,
5
);
...
...
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