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
b7159f4d
Commit
b7159f4d
authored
Nov 13, 2011
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hello world example
parent
ac6327a0
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
77 additions
and
7 deletions
+77
-7
.gitignore
.gitignore
+7
-1
cppa.files
cppa.files
+1
-0
cppa/cppa.hpp
cppa/cppa.hpp
+20
-2
cppa/on.hpp
cppa/on.hpp
+1
-1
examples/Makefile.am
examples/Makefile.am
+4
-1
examples/hello_world_example.cpp
examples/hello_world_example.cpp
+42
-0
libcppa.doxygen
libcppa.doxygen
+1
-1
unit_testing/test__pattern.cpp
unit_testing/test__pattern.cpp
+1
-1
No files found.
.gitignore
View file @
b7159f4d
...
@@ -44,4 +44,10 @@ Makefile
...
@@ -44,4 +44,10 @@ Makefile
unit_testing/Makefile
unit_testing/Makefile
libcppa.so*
libcppa.so*
blob/cppatest
blob/cppatest
callgrind.out.*
callgrind.out*
examples/announce_example_1
examples/announce_example_2
examples/announce_example_3
examples/announce_example_4
examples/announce_example_5
examples/hello_world_example
cppa.files
View file @
b7159f4d
...
@@ -234,3 +234,4 @@ examples/announce_example_2.cpp
...
@@ -234,3 +234,4 @@ examples/announce_example_2.cpp
examples/announce_example_3.cpp
examples/announce_example_3.cpp
examples/announce_example_4.cpp
examples/announce_example_4.cpp
examples/announce_example_5.cpp
examples/announce_example_5.cpp
examples/hello_world_example.cpp
cppa/cppa.hpp
View file @
b7159f4d
...
@@ -64,6 +64,19 @@
...
@@ -64,6 +64,19 @@
* @section Intro Introduction
* @section Intro Introduction
*
*
* This library provides an implementation of the Actor model for C++.
* This library provides an implementation of the Actor model for C++.
* It uses a network transparent messaging system to ease development
* of both concurrent and distributed software using C++.
*
* @p libcppa uses a thread pool to schedule actors by default.
* Individual actors can be spawned (created) with a special flag to run in
* an own thread if needed.
*
* In @p libcppa, each context is an actor. Even main is implicitly
* converted to an actor if needed.
*
* @subsection IntroHelloWorld Hello World Example
*
* @include hello_world_example.cpp
*
*
* @section GettingStarted Getting started with libcppa
* @section GettingStarted Getting started with libcppa
*
*
...
@@ -86,7 +99,7 @@
...
@@ -86,7 +99,7 @@
* @p libcppa uses a copy-on-write optimization for its message
* @p libcppa uses a copy-on-write optimization for its message
* passing implementation.
* passing implementation.
*
*
* {@link tuple Tuples} should @b always be used
used
with by-value semantic,
* {@link tuple Tuples} should @b always be used with by-value semantic,
* since tuples use a copy-on-write smart pointer internally. Let's assume two
* since tuples use a copy-on-write smart pointer internally. Let's assume two
* tuple @p x and @p y, whereas @p y is a copy of @p x:
* tuple @p x and @p y, whereas @p y is a copy of @p x:
*
*
...
@@ -145,6 +158,11 @@
...
@@ -145,6 +158,11 @@
* // x has the type tuple<std::string, std::string>
* // x has the type tuple<std::string, std::string>
* auto x = make_tuple("hello", "tuple");
* auto x = make_tuple("hello", "tuple");
*
*
* receive
* (
* // equal to on(std::string("hello actor!"))
* on("hello actor!") >> []() { }
* );
* @endcode
* @endcode
*/
*/
...
@@ -532,7 +550,7 @@ local_actor* operator<<(local_actor* whom, any_tuple&& what);
...
@@ -532,7 +550,7 @@ local_actor* operator<<(local_actor* whom, any_tuple&& what);
#endif
#endif
template
<
class
C
,
typename
Arg0
,
typename
...
Args
>
template
<
typename
Arg0
,
typename
...
Args
>
void
reply
(
const
Arg0
&
arg0
,
const
Args
&
...
args
)
void
reply
(
const
Arg0
&
arg0
,
const
Args
&
...
args
)
{
{
send
(
self
()
->
mailbox
().
last_sender
(),
arg0
,
args
...);
send
(
self
()
->
mailbox
().
last_sender
(),
arg0
,
args
...);
...
...
cppa/on.hpp
View file @
b7159f4d
...
@@ -117,7 +117,7 @@ constexpr typename detail::boxed<T>::type val()
...
@@ -117,7 +117,7 @@ constexpr typename detail::boxed<T>::type val()
//constexpr detail::boxed<anything> any_vals = detail::boxed<anything>();
//constexpr detail::boxed<anything> any_vals = detail::boxed<anything>();
constexpr
anything
any_vals
=
anything
();
constexpr
anything
any_vals
=
anything
();
constexpr
detail
::
on_the_fly_invoke_rule_builder
on_
param
_match
()
constexpr
detail
::
on_the_fly_invoke_rule_builder
on_
arg
_match
()
{
{
return
{
};
return
{
};
}
}
...
...
examples/Makefile.am
View file @
b7159f4d
...
@@ -7,13 +7,15 @@ noinst_PROGRAMS = announce_example_1 \
...
@@ -7,13 +7,15 @@ noinst_PROGRAMS = announce_example_1 \
announce_example_2
\
announce_example_2
\
announce_example_3
\
announce_example_3
\
announce_example_4
\
announce_example_4
\
announce_example_5
announce_example_5
\
hello_world_example
announce_example_1_SOURCES
=
announce_example_1.cpp
announce_example_1_SOURCES
=
announce_example_1.cpp
announce_example_2_SOURCES
=
announce_example_2.cpp
announce_example_2_SOURCES
=
announce_example_2.cpp
announce_example_3_SOURCES
=
announce_example_3.cpp
announce_example_3_SOURCES
=
announce_example_3.cpp
announce_example_4_SOURCES
=
announce_example_4.cpp
announce_example_4_SOURCES
=
announce_example_4.cpp
announce_example_5_SOURCES
=
announce_example_5.cpp
announce_example_5_SOURCES
=
announce_example_5.cpp
hello_world_example_SOURCES
=
hello_world_example.cpp
EXAMPLES_LIBS
=
$(BOOST_LDFLAGS)
$(BOOST_THREAD_LIB)
-L
../.libs/
-lcppa
EXAMPLES_LIBS
=
$(BOOST_LDFLAGS)
$(BOOST_THREAD_LIB)
-L
../.libs/
-lcppa
...
@@ -22,4 +24,5 @@ announce_example_2_LDADD = $(EXAMPLES_LIBS)
...
@@ -22,4 +24,5 @@ announce_example_2_LDADD = $(EXAMPLES_LIBS)
announce_example_3_LDADD
=
$(EXAMPLES_LIBS)
announce_example_3_LDADD
=
$(EXAMPLES_LIBS)
announce_example_4_LDADD
=
$(EXAMPLES_LIBS)
announce_example_4_LDADD
=
$(EXAMPLES_LIBS)
announce_example_5_LDADD
=
$(EXAMPLES_LIBS)
announce_example_5_LDADD
=
$(EXAMPLES_LIBS)
hello_world_example_LDADD
=
$(EXAMPLES_LIBS)
examples/hello_world_example.cpp
0 → 100644
View file @
b7159f4d
#include <string>
#include <iostream>
#include "cppa/cppa.hpp"
using
namespace
cppa
;
void
echo_actor
()
{
// wait for a message
receive
(
// invoke this lambda expression if we receive a string
on
<
std
::
string
>
()
>>
[](
const
std
::
string
&
what
)
{
// prints "Hello World!"
std
::
cout
<<
what
<<
std
::
endl
;
// reply "!dlroW olleH"
reply
(
std
::
string
(
what
.
rbegin
(),
what
.
rend
()));
}
);
}
int
main
()
{
// create a new actor that invokes the function echo_actor
auto
hello_actor
=
spawn
(
echo_actor
);
// send "Hello World!" to our new actor
// note: libcppa converts string literals to std::string objects
send
(
hello_actor
,
"Hello World!"
);
// wait for a response and print it
receive
(
on
<
std
::
string
>
()
>>
[](
const
std
::
string
&
what
)
{
std
::
cout
<<
what
<<
std
::
endl
;
}
);
// wait until all other actors we've spawned are done
await_all_others_done
();
// done
return
0
;
}
libcppa.doxygen
View file @
b7159f4d
...
@@ -622,7 +622,7 @@ EXCLUDE_SYMBOLS =
...
@@ -622,7 +622,7 @@ EXCLUDE_SYMBOLS =
# directories that contain example code fragments that are included (see
# directories that contain example code fragments that are included (see
# the \include command).
# the \include command).
EXAMPLE_PATH =
documentation
EXAMPLE_PATH =
examples
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
...
...
unit_testing/test__pattern.cpp
View file @
b7159f4d
...
@@ -83,7 +83,7 @@ size_t test__pattern()
...
@@ -83,7 +83,7 @@ size_t test__pattern()
CPPA_CHECK_EQUAL
(
value
,
1
);
CPPA_CHECK_EQUAL
(
value
,
1
);
lambda_invoked
[
4
]
=
true
;
lambda_invoked
[
4
]
=
true
;
},
},
on_
param
_match
()
>>
[
&
](
double
v1
,
const
float
&
v2
)
on_
arg
_match
()
>>
[
&
](
double
v1
,
const
float
&
v2
)
{
{
CPPA_CHECK_EQUAL
(
v1
,
1.0
);
CPPA_CHECK_EQUAL
(
v1
,
1.0
);
CPPA_CHECK_EQUAL
(
v2
,
2.0
f
);
CPPA_CHECK_EQUAL
(
v2
,
2.0
f
);
...
...
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