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
466b6322
Commit
466b6322
authored
Mar 09, 2011
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restructuring
parent
4aaf8427
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
239 additions
and
124 deletions
+239
-124
.gitignore
.gitignore
+1
-0
Makefile
Makefile
+2
-2
cppa.creator.user
cppa.creator.user
+4
-4
cppa.files
cppa.files
+13
-10
cppa.includes
cppa.includes
+1
-0
cppa/actor.hpp
cppa/actor.hpp
+6
-0
unit_testing/Makefile
unit_testing/Makefile
+18
-16
unit_testing/main.cpp
unit_testing/main.cpp
+3
-1
unit_testing/test.hpp
unit_testing/test.hpp
+5
-0
unit_testing/test__a_matches_b.cpp
unit_testing/test__a_matches_b.cpp
+1
-1
unit_testing/test__atom.cpp
unit_testing/test__atom.cpp
+1
-65
unit_testing/test__intrusive_ptr.cpp
unit_testing/test__intrusive_ptr.cpp
+1
-1
unit_testing/test__local_group.cpp
unit_testing/test__local_group.cpp
+173
-0
unit_testing/test__queue_performance.cpp
unit_testing/test__queue_performance.cpp
+1
-1
unit_testing/test__serialization.cpp
unit_testing/test__serialization.cpp
+2
-1
unit_testing/test__spawn.cpp
unit_testing/test__spawn.cpp
+3
-20
unit_testing/test__tuple.cpp
unit_testing/test__tuple.cpp
+2
-1
unit_testing/test__type_list.cpp
unit_testing/test__type_list.cpp
+2
-1
No files found.
.gitignore
View file @
466b6322
.DS_Store
*.o
*.dylib
test
Makefile
View file @
466b6322
all
:
make
-f
libcppa.Makefile
make
-
f
test.Makefile
make
-
C
unit_testing
clean
:
make
-f
libcppa.Makefile clean
make
-
f
test.Makefile
clean
make
-
C
unit_testing
clean
cppa.creator.user
View file @
466b6322
...
...
@@ -60,15 +60,15 @@
<valuemap
type=
"QVariantMap"
>
<value
key=
"ProjectExplorer.BuildConfiguration.DisplayName"
type=
"QString"
>
all
</value>
<valuelist
key=
"abstractProcess.Environment"
type=
"QVariantList"
>
<value
type=
"QString"
>
Apple_PubSub_Socket_Render=/tmp/launch-
omyHKo
/Render
</value>
<value
type=
"QString"
>
Apple_PubSub_Socket_Render=/tmp/launch-
Ii2KqP
/Render
</value>
<value
type=
"QString"
>
COMMAND_MODE=unix2003
</value>
<value
type=
"QString"
>
DISPLAY=/tmp/launch-
fg6icm
/org.x:0
</value>
<value
type=
"QString"
>
DISPLAY=/tmp/launch-
6FAyZP
/org.x:0
</value>
<value
type=
"QString"
>
HOME=/Users/neverlord
</value>
<value
type=
"QString"
>
LOGNAME=neverlord
</value>
<value
type=
"QString"
>
PATH=/usr/bin:/bin:/usr/sbin:/sbin
</value>
<value
type=
"QString"
>
SHELL=/bin/bash
</value>
<value
type=
"QString"
>
SSH_AUTH_SOCK=/tmp/launch-
3s45KF
/Listeners
</value>
<value
type=
"QString"
>
TMPDIR=/var/folders/
SE/SEReyCW0H-yDPCnNCe8mN+
+++TI/-Tmp-/
</value>
<value
type=
"QString"
>
SSH_AUTH_SOCK=/tmp/launch-
vifjfO
/Listeners
</value>
<value
type=
"QString"
>
TMPDIR=/var/folders/
1p/1p6iuPgbH7GoDkrjrT20tU
+++TI/-Tmp-/
</value>
<value
type=
"QString"
>
USER=neverlord
</value>
<value
type=
"QString"
>
__CF_USER_TEXT_ENCODING=0x1F5:0:3
</value>
</valuelist>
...
...
cppa.files
View file @
466b6322
cppa/ref_counted.hpp
cppa/tuple.hpp
src
/main.cpp
unit_testing
/main.cpp
src/ref_counted.cpp
cppa/util/void_type.hpp
cppa/util/type_list.hpp
...
...
@@ -10,12 +10,12 @@ cppa/util.hpp
cppa/util/is_one_of.hpp
cppa/util/conjunction.hpp
cppa/util/disjunction.hpp
cppa
/test.hpp
src
/test__a_matches_b.cpp
unit_testing
/test.hpp
unit_testing
/test__a_matches_b.cpp
cppa/uniform_type_info.hpp
src/uniform_type_info.cpp
cppa/config.hpp
src
/test__tuple.cpp
unit_testing
/test__tuple.cpp
cppa/detail/abstract_tuple.hpp
cppa/tuple_view.hpp
cppa/untyped_tuple.hpp
...
...
@@ -31,17 +31,17 @@ cppa/util/detach.hpp
cppa/detail/ref_counted_impl.hpp
cppa/intrusive_ptr.hpp
cppa/detail/scheduler.hpp
src
/test__spawn.cpp
unit_testing
/test__spawn.cpp
src/mock_scheduler.cpp
cppa/actor.hpp
cppa/message.hpp
src
/test__intrusive_ptr.cpp
unit_testing
/test__intrusive_ptr.cpp
cppa/util/concat_type_lists.hpp
cppa/util/filter_type_list.hpp
cppa/util/is_comparable.hpp
cppa/util/callable_trait.hpp
cppa/util/reverse_type_list.hpp
src
/test__type_list.cpp
unit_testing
/test__type_list.cpp
cppa/util/remove_const_reference.hpp
cppa/util/type_list_apply.hpp
cppa/util/eval_type_lists.hpp
...
...
@@ -56,7 +56,7 @@ cppa/invoke_rules.hpp
cppa/util/type_list_pop_back.hpp
cppa/invoke.hpp
cppa/on.hpp
src
/test__serialization.cpp
unit_testing
/test__serialization.cpp
cppa/serializer.hpp
cppa/deserializer.hpp
cppa/util/is_serializable.hpp
...
...
@@ -76,8 +76,8 @@ cppa/util/sink.hpp
src/untyped_tuple.cpp
cppa/util/abstract_type_list.hpp
cppa/detail/serialize_tuple.hpp
src
/test__atom.cpp
src
/test__queue_performance.cpp
unit_testing
/test__atom.cpp
unit_testing
/test__queue_performance.cpp
cppa/detail/actor_public.hpp
cppa/detail/comparable.hpp
cppa/util/single_reader_queue.hpp
...
...
@@ -85,3 +85,6 @@ cppa/util/singly_linked_list.hpp
cppa/detail/spawn_impl.hpp
cppa/detail/actor_private.hpp
cppa/reply.hpp
unit_testing/test__local_group.cpp
unit_testing/hash_of.cpp
cppa/spawn.hpp
cppa.includes
View file @
466b6322
/Users/neverlord/libcppa
/opt/local/include/gcc45/c++
/Users/neverlord/libcppa/unit_testing
cppa/actor.hpp
View file @
466b6322
...
...
@@ -47,6 +47,12 @@ class actor
this_actor
()
->
send
(
m_ptr
.
get
(),
args
);
}
inline
bool
operator
==
(
const
actor
&
other
)
const
{
return
m_ptr
==
other
.
m_ptr
;
}
private:
ptr_type
m_ptr
;
...
...
test.
Makefile
→
unit_testing/
Makefile
View file @
466b6322
...
...
@@ -2,22 +2,24 @@ 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
INCLUDES = -I./
EXECUTABLE = test
HEADERS = cppa/test.hpp
SOURCES = src/main.cpp \
src/test__a_matches_b.cpp \
src/test__atom.cpp \
src/test__intrusive_ptr.cpp \
src/test__queue_performance.cpp \
src/test__serialization.cpp \
src/test__spawn.cpp \
src/test__tuple.cpp \
src/test__type_list.cpp
LIBS
=
-L
/opt/local/lib
-lboost_thread-mt
-L
../
-lcppa
INCLUDES
=
-I
./
-I
../
EXECUTABLE
=
../test
HEADERS
=
test.hpp
SOURCES
=
hash_of.cpp
\
main.cpp
\
test__a_matches_b.cpp
\
test__atom.cpp
\
test__intrusive_ptr.cpp
\
test__local_group.cpp
\
test__queue_performance.cpp
\
test__serialization.cpp
\
test__spawn.cpp
\
test__tuple.cpp
\
test__type_list.cpp
OBJECTS
=
$(SOURCES:.cpp=.o)
...
...
src
/main.cpp
→
unit_testing
/main.cpp
View file @
466b6322
...
...
@@ -9,7 +9,8 @@
#include <typeinfo>
#include <iostream>
#include "cppa/test.hpp"
#include "test.hpp"
#include "cppa/tuple.hpp"
#include "cppa/config.hpp"
#include "cppa/uniform_type_info.hpp"
...
...
@@ -59,6 +60,7 @@ int main(int argc, char** c_argv)
RUN_TEST
(
test__type_list
);
RUN_TEST
(
test__serialization
);
RUN_TEST
(
test__atom
);
RUN_TEST
(
test__local_group
);
cout
<<
endl
<<
"error(s) in all tests: "
<<
errors
<<
endl
;
...
...
cppa
/test.hpp
→
unit_testing
/test.hpp
View file @
466b6322
...
...
@@ -34,6 +34,10 @@ if ((lhs_loc) != (rhs_loc)) \
++error_count; \
} ((void) 0)
unsigned
int
hash_of
(
const
char
*
what
,
int
what_length
);
unsigned
int
hash_of
(
const
std
::
string
&
what
);
std
::
size_t
test__type_list
();
std
::
size_t
test__a_matches_b
();
std
::
size_t
test__atom
();
...
...
@@ -41,6 +45,7 @@ std::size_t test__tuple();
std
::
size_t
test__spawn
();
std
::
size_t
test__intrusive_ptr
();
std
::
size_t
test__serialization
();
std
::
size_t
test__local_group
();
void
test__queue_performance
();
...
...
src
/test__a_matches_b.cpp
→
unit_testing
/test__a_matches_b.cpp
View file @
466b6322
#include <string>
#include <typeinfo>
#include "
cppa/
test.hpp"
#include "test.hpp"
#include "cppa/util.hpp"
using
namespace
cppa
;
...
...
src
/test__atom.cpp
→
unit_testing
/test__atom.cpp
View file @
466b6322
...
...
@@ -2,7 +2,7 @@
#include <typeinfo>
#include <iostream>
#include "
cppa/
test.hpp"
#include "test.hpp"
#include "cppa/util.hpp"
using
std
::
cout
;
...
...
@@ -11,70 +11,6 @@ using std::endl;
using
namespace
cppa
;
using
namespace
cppa
::
util
;
unsigned
int
MurmurHash2
(
const
void
*
key
,
int
len
,
unsigned
int
seed
)
{
static_assert
(
sizeof
(
int
)
==
4
,
"MurmurHash2 requires sizeof(int) == 4"
);
// 'm' and 'r' are mixing constants generated offline.
// They're not really 'magic', they just happen to work well.
const
unsigned
int
m
=
0x5bd1e995
;
const
int
r
=
24
;
// Initialize the hash to a 'random' value
unsigned
int
h
=
seed
^
len
;
// Mix 4 bytes at a time into the hash
const
unsigned
char
*
data
=
(
const
unsigned
char
*
)
key
;
while
(
len
>=
4
)
{
unsigned
int
k
=
*
(
unsigned
int
*
)
data
;
k
*=
m
;
k
^=
k
>>
r
;
k
*=
m
;
h
*=
m
;
h
^=
k
;
data
+=
4
;
len
-=
4
;
}
// Handle the last few bytes of the input array
switch
(
len
)
{
case
3
:
h
^=
data
[
2
]
<<
16
;
case
2
:
h
^=
data
[
1
]
<<
8
;
case
1
:
h
^=
data
[
0
];
h
*=
m
;
};
// Do a few final mixes of the hash to ensure the last few
// bytes are well-incorporated.
h
^=
h
>>
13
;
h
*=
m
;
h
^=
h
>>
15
;
return
h
;
}
unsigned
int
hash_of
(
const
char
*
what
,
int
what_length
)
{
return
MurmurHash2
(
what
,
what_length
,
0x15091984
);
}
unsigned
int
hash_of
(
const
std
::
string
&
what
)
{
return
MurmurHash2
(
what
.
c_str
(),
what
.
size
(),
0x15091984
);
}
template
<
char
...
Str
>
struct
_tostring
;
...
...
src
/test__intrusive_ptr.cpp
→
unit_testing
/test__intrusive_ptr.cpp
View file @
466b6322
#include <list>
#include <cstddef>
#include "
cppa/
test.hpp"
#include "test.hpp"
#include "cppa/intrusive_ptr.hpp"
#include "cppa/detail/ref_counted_impl.hpp"
...
...
unit_testing/test__local_group.cpp
0 → 100644
View file @
466b6322
#include "test.hpp"
#include "cppa/on.hpp"
#include "cppa/spawn.hpp"
#include "cppa/reply.hpp"
#include "cppa/actor.hpp"
#include "cppa/ref_counted.hpp"
#include "cppa/intrusive_ptr.hpp"
#include <map>
#include <list>
#include <iostream>
#include <algorithm>
#include <boost/thread/mutex.hpp>
using
std
::
cout
;
using
std
::
endl
;
using
namespace
cppa
;
class
group
:
public
ref_counted
{
boost
::
mutex
m_mtx
;
std
::
list
<
actor
>
m_subscribers
;
public:
struct
subscription
{
actor
m_self
;
intrusive_ptr
<
group
>
m_group
;
subscription
(
const
actor
&
s
,
const
intrusive_ptr
<
group
>&
g
)
:
m_self
(
s
),
m_group
(
g
)
{
}
~
subscription
()
{
m_group
->
unsubscribe
(
m_self
);
}
};
subscription
subscribe
(
const
actor
&
who
)
{
boost
::
mutex
::
scoped_lock
guard
(
m_mtx
);
m_subscribers
.
push_back
(
who
);
return
{
who
,
this
};
}
void
unsubscribe
(
const
actor
&
who
)
{
boost
::
mutex
::
scoped_lock
guard
(
m_mtx
);
auto
i
=
std
::
find
(
m_subscribers
.
begin
(),
m_subscribers
.
end
(),
who
);
if
(
i
!=
m_subscribers
.
end
())
{
m_subscribers
.
erase
(
i
);
}
}
template
<
typename
...
Args
>
void
send
(
const
Args
&
...
args
)
{
boost
::
mutex
::
scoped_lock
guard
(
m_mtx
);
for
(
auto
i
=
m_subscribers
.
begin
();
i
!=
m_subscribers
.
end
();
++
i
)
{
i
->
send
(
args
...);
}
}
};
namespace
{
class
group_bucket
{
boost
::
mutex
m_mtx
;
std
::
map
<
std
::
string
,
intrusive_ptr
<
group
>>
m_groups
;
public:
intrusive_ptr
<
group
>
get
(
const
std
::
string
&
group_name
)
{
boost
::
mutex
::
scoped_lock
guard
(
m_mtx
);
intrusive_ptr
<
group
>&
result
=
m_groups
[
group_name
];
if
(
!
result
)
{
result
.
reset
(
new
group
);
}
return
result
;
}
};
template
<
std
::
size_t
NumBuckets
>
class
group_table
{
group_bucket
m_buckets
[
NumBuckets
];
group_bucket
&
bucket
(
const
std
::
string
&
group_name
)
{
unsigned
int
gn_hash
=
hash_of
(
group_name
);
return
m_buckets
[
gn_hash
%
NumBuckets
];
}
public:
intrusive_ptr
<
group
>
operator
[](
const
std
::
string
&
group_name
)
{
return
bucket
(
group_name
).
get
(
group_name
);
}
};
group_table
<
100
>
m_groups
;
}
// namespace <anonymous>
struct
{
intrusive_ptr
<
group
>
operator
/
(
const
std
::
string
&
group_name
)
{
return
m_groups
[
group_name
];
}
}
local
;
void
foo_actor
()
{
auto
x
=
(
local
/
"foobar"
)
->
subscribe
(
this_actor
());
receive
(
on
<
int
,
int
,
int
>
()
>>
[]()
{
reply
(
23.
f
);
});
receive
(
on
<
int
>
()
>>
[](
int
i
)
{
reply
(
i
);
});
}
std
::
size_t
test__local_group
()
{
CPPA_TEST
(
test__local_group
);
auto
g
=
local
/
"foobar"
;
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
spawn
(
foo_actor
).
send
(
1
,
2
,
3
);
}
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
receive
(
on
<
float
>
()
>>
[
&
]()
{
});
}
g
->
send
(
1
);
int
result
=
0
;
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
receive
(
on
<
int
>
()
>>
[
&
](
int
x
)
{
result
+=
x
;
});
}
CPPA_CHECK_EQUAL
(
result
,
5
);
return
CPPA_TEST_RESULT
;
}
src
/test__queue_performance.cpp
→
unit_testing
/test__queue_performance.cpp
View file @
466b6322
#include <list>
#include <atomic>
#include <iostream>
#include "
cppa/
test.hpp"
#include "test.hpp"
#include <boost/ref.hpp>
#include <boost/thread.hpp>
...
...
src
/test__serialization.cpp
→
unit_testing
/test__serialization.cpp
View file @
466b6322
...
...
@@ -8,7 +8,8 @@
#include <iostream>
#include <type_traits>
#include "cppa/test.hpp"
#include "test.hpp"
#include "cppa/util.hpp"
#include "cppa/match.hpp"
#include "cppa/tuple.hpp"
...
...
src
/test__spawn.cpp
→
unit_testing
/test__spawn.cpp
View file @
466b6322
#include <iostream>
#include <functional>
#include "test.hpp"
#include "cppa/on.hpp"
#include "cppa/test.hpp"
#include "cppa/actor.hpp"
#include "cppa/spawn.hpp"
#include "cppa/detail/scheduler.hpp"
using
std
::
cout
;
...
...
@@ -11,25 +13,6 @@ using std::endl;
using
namespace
cppa
;
template
<
typename
F
>
actor
spawn
(
F
act_fun
)
{
struct
bhv
:
cppa
::
detail
::
behavior
{
std
::
function
<
void
()
>
m_act
;
bhv
(
const
F
&
invokable
)
:
m_act
(
invokable
)
{
}
virtual
void
act
()
{
m_act
();
}
virtual
void
on_exit
()
{
}
};
return
cppa
::
detail
::
spawn_impl
(
new
bhv
(
act_fun
));
// return actor();
}
void
pong
()
{
receive
(
on
<
int
>
()
>>
[](
int
value
)
{
...
...
src
/test__tuple.cpp
→
unit_testing
/test__tuple.cpp
View file @
466b6322
...
...
@@ -5,9 +5,10 @@
#include <typeinfo>
#include <functional>
#include "test.hpp"
#include "cppa/on.hpp"
#include "cppa/util.hpp"
#include "cppa/test.hpp"
#include "cppa/tuple.hpp"
#include "cppa/match.hpp"
#include "cppa/invoke.hpp"
...
...
src
/test__type_list.cpp
→
unit_testing
/test__type_list.cpp
View file @
466b6322
...
...
@@ -2,8 +2,9 @@
#include <typeinfo>
#include <type_traits>
#include "test.hpp"
#include "cppa/util.hpp"
#include "cppa/test.hpp"
#include "cppa/uniform_type_info.hpp"
using
std
::
cout
;
...
...
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