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
9e34fdf9
Commit
9e34fdf9
authored
Apr 25, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfixing
parent
b61316b9
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
281 additions
and
137 deletions
+281
-137
cppa/config.hpp
cppa/config.hpp
+10
-11
cppa/detail/addressed_message.hpp
cppa/detail/addressed_message.hpp
+1
-7
cppa/detail/thread.hpp
cppa/detail/thread.hpp
+3
-1
src/actor_proxy.cpp
src/actor_proxy.cpp
+2
-1
src/addressed_message.cpp
src/addressed_message.cpp
+2
-11
src/mailman.cpp
src/mailman.cpp
+2
-1
src/post_office.cpp
src/post_office.cpp
+169
-82
src/thread_pool_scheduler.cpp
src/thread_pool_scheduler.cpp
+8
-2
src/to_uniform_name.cpp
src/to_uniform_name.cpp
+2
-1
src/unicast_network.cpp
src/unicast_network.cpp
+6
-3
src/uniform_type_info.cpp
src/uniform_type_info.cpp
+65
-8
unit_testing/main.cpp
unit_testing/main.cpp
+2
-2
unit_testing/test__remote_actor.cpp
unit_testing/test__remote_actor.cpp
+2
-1
unit_testing/test__uniform_type.cpp
unit_testing/test__uniform_type.cpp
+7
-6
No files found.
cppa/config.hpp
View file @
9e34fdf9
...
...
@@ -66,9 +66,10 @@
# error Plattform and/or compiler not supported
#endif
#ifdef CPPA_DEBUG
#include <cstdio>
#include <cstdlib>
#ifdef CPPA_DEBUG
#include <execinfo.h>
#define CPPA_REQUIRE__(stmt, file, line) \
...
...
@@ -83,18 +84,16 @@
if ((stmt) == false) { \
CPPA_REQUIRE__(#stmt, __FILE__, __LINE__); \
}((void) 0)
#define CPPA_CRITICAL__(error, file, line) \
printf("%s:%u: critical error: '%s'\n", file, line, error); \
{ \
void *array[10]; \
size_t size = backtrace(array, 10); \
backtrace_symbols_fd(array, size, 2); \
} \
exit(7)
#define CPPA_CRITICAL(error) CPPA_CRITICAL__(error, __FILE__, __LINE__)
#else // CPPA_DEBUG
#define CPPA_REQUIRE(unused) ((void) 0)
#define CPPA_CRITICAL(unused) exit(7)
#endif // CPPA_DEBUG
#define CPPA_CRITICAL__(error, file, line) \
{ \
printf("%s:%u: critical error: '%s'\n", file, line, error); \
exit(7); \
} ((void) 0)
#define CPPA_CRITICAL(error) CPPA_CRITICAL__(error, __FILE__, __LINE__)
#endif // CPPA_CONFIG_HPP
cppa/detail/addressed_message.hpp
View file @
9e34fdf9
...
...
@@ -45,13 +45,7 @@ class addressed_message
public:
addressed_message
(
actor_ptr
const
&
from
,
channel_ptr
const
&
to
,
any_tuple
const
&
ut
);
addressed_message
(
actor_ptr
const
&
from
,
channel_ptr
const
&
to
,
any_tuple
&&
ut
);
addressed_message
(
actor_ptr
from
,
channel_ptr
to
,
any_tuple
ut
);
addressed_message
()
=
default
;
addressed_message
(
addressed_message
&&
)
=
default
;
...
...
cppa/detail/thread.hpp
View file @
9e34fdf9
...
...
@@ -31,7 +31,9 @@
#ifndef THREAD_HPP
#define THREAD_HPP
#ifdef __APPLE__
//#ifdef __APPLE__
#if 1
#include <boost/thread.hpp>
#include "cppa/util/duration.hpp"
...
...
src/actor_proxy.cpp
View file @
9e34fdf9
...
...
@@ -49,8 +49,9 @@ void actor_proxy::forward_message(process_information_ptr const& piptr,
actor
*
sender
,
any_tuple
&&
msg
)
{
detail
::
addressed_message
amsg
{
sender
,
this
,
std
::
move
(
msg
)};
detail
::
singleton_manager
::
get_network_manager
()
->
send_to_mailman
(
make_any_tuple
(
piptr
,
actor_ptr
{
sender
},
std
::
move
(
msg
)));
->
send_to_mailman
(
make_any_tuple
(
piptr
,
std
::
move
(
a
msg
)));
}
void
actor_proxy
::
enqueue
(
actor
*
sender
,
any_tuple
msg
)
...
...
src/addressed_message.cpp
View file @
9e34fdf9
...
...
@@ -33,17 +33,8 @@
namespace
cppa
{
namespace
detail
{
addressed_message
::
addressed_message
(
const
actor_ptr
&
from
,
const
channel_ptr
&
to
,
const
any_tuple
&
ut
)
:
m_sender
(
from
),
m_receiver
(
to
),
m_content
(
ut
)
{
}
addressed_message
::
addressed_message
(
const
actor_ptr
&
from
,
const
channel_ptr
&
to
,
any_tuple
&&
ut
)
:
m_sender
(
from
),
m_receiver
(
to
),
m_content
(
std
::
move
(
ut
))
addressed_message
::
addressed_message
(
actor_ptr
from
,
channel_ptr
to
,
any_tuple
ut
)
:
m_sender
(
std
::
move
(
from
)),
m_receiver
(
std
::
move
(
to
)),
m_content
(
std
::
move
(
ut
))
{
}
...
...
src/mailman.cpp
View file @
9e34fdf9
...
...
@@ -99,11 +99,12 @@ void mailman_loop()
}
else
{
DEBUG
(
"message to an unknown peer
"
);
DEBUG
(
"message to an unknown peer
: "
<<
to_string
(
msg
)
);
}
},
on_arg_match
>>
[
&
](
native_socket_type
sockfd
,
process_information_ptr
pinfo
)
{
DEBUG
(
"mailman: add_peer"
);
auto
i
=
peers
.
find
(
*
pinfo
);
if
(
i
==
peers
.
end
())
{
...
...
src/post_office.cpp
View file @
9e34fdf9
This diff is collapsed.
Click to expand it.
src/thread_pool_scheduler.cpp
View file @
9e34fdf9
...
...
@@ -100,7 +100,8 @@ struct thread_pool_scheduler::worker
{
return
result
;
}
# ifdef __APPLE__
# if 1
//# ifdef __APPLE__
auto
timeout
=
boost
::
get_system_time
();
timeout
+=
boost
::
posix_time
::
milliseconds
(
1
);
boost
::
this_thread
::
sleep
(
timeout
);
...
...
@@ -121,7 +122,8 @@ struct thread_pool_scheduler::worker
{
return
result
;
}
# ifdef __APPLE__
# if 1
//# ifdef __APPLE__
auto
timeout
=
boost
::
get_system_time
();
timeout
+=
boost
::
posix_time
::
milliseconds
(
10
);
boost
::
this_thread
::
sleep
(
timeout
);
...
...
@@ -154,6 +156,9 @@ struct thread_pool_scheduler::worker
handler
h
;
for
(;;)
{
h
.
job
=
aggressive_polling
();
while
(
!
h
.
job
)
h
.
job
=
less_aggressive_polling
();
/*
h.job = aggressive_polling();
if (!h.job)
{
...
...
@@ -163,6 +168,7 @@ struct thread_pool_scheduler::worker
h.job = relaxed_polling();
}
}
*/
if
(
h
.
job
==
m_dummy
)
{
// dummy of doom received ...
...
...
src/to_uniform_name.cpp
View file @
9e34fdf9
...
...
@@ -125,7 +125,8 @@ std::string to_uniform_name_impl(Iterator begin, Iterator end,
{
demangled
<
cppa
::
actor_ptr
>
(),
"@actor"
},
{
demangled
<
cppa
::
group_ptr
>
(),
"@group"
},
{
demangled
<
cppa
::
channel_ptr
>
(),
"@channel"
},
{
demangled
<
cppa
::
detail
::
addressed_message
>
(),
"@msg"
}
{
demangled
<
cppa
::
detail
::
addressed_message
>
(),
"@msg"
},
{
demangled
<
cppa
::
intrusive_ptr
<
cppa
::
process_information
>
>
(),
"@process_info"
}
};
// check if we could find the whole string in our lookup map
...
...
src/unicast_network.cpp
View file @
9e34fdf9
...
...
@@ -133,6 +133,10 @@ void publish(actor_ptr& whom, std::uint16_t port)
{
throw
network_error
(
"unable to get socket flags"
);
}
if
(
fcntl
(
sockfd
,
F_SETFL
,
flags
|
O_NONBLOCK
)
<
0
)
{
throw
network_error
(
"unable to set socket to nonblock"
);
}
if
(
bind
(
sockfd
,
(
struct
sockaddr
*
)
&
serv_addr
,
sizeof
(
serv_addr
))
<
0
)
{
throw
bind_failure
(
errno
);
...
...
@@ -172,7 +176,7 @@ actor_ptr remote_actor(const char* host, std::uint16_t port)
serv_addr
.
sin_family
=
AF_INET
;
memmove
(
&
serv_addr
.
sin_addr
.
s_addr
,
server
->
h_addr
,
server
->
h_length
);
serv_addr
.
sin_port
=
htons
(
port
);
if
(
connect
(
sockfd
,
(
const
sockaddr
*
)
&
serv_addr
,
sizeof
(
serv_addr
))
<
0
)
if
(
connect
(
sockfd
,
(
const
sockaddr
*
)
&
serv_addr
,
sizeof
(
serv_addr
))
!=
0
)
{
throw
network_error
(
"could not connect to host"
);
}
...
...
@@ -189,12 +193,11 @@ actor_ptr remote_actor(const char* host, std::uint16_t port)
auto
peer_pinf
=
new
process_information
(
peer_pid
,
peer_node_id
);
process_information_ptr
pinfptr
(
peer_pinf
);
auto
key
=
std
::
make_tuple
(
remote_actor_id
,
pinfptr
->
process_id
(),
pinfptr
->
node_id
());
auto
result
=
detail
::
get_actor_proxy_cache
().
get
(
key
);
detail
::
singleton_manager
::
get_network_manager
()
->
send_to_mailman
(
make_any_tuple
(
sockfd
,
pinfptr
));
detail
::
post_office_add_peer
(
sockfd
,
pinfptr
);
return
detail
::
get_actor_proxy_cache
().
get
(
key
);
//auto ptr = get_scheduler()->register_hidden_context();
return
result
;
}
}
// namespace cppa
src/uniform_type_info.cpp
View file @
9e34fdf9
...
...
@@ -158,7 +158,7 @@ class void_type_tinfo : public util::abstract_uniform_type_info<void_type>
protected:
void
serialize
(
const
void
*
,
serializer
*
sink
)
const
void
serialize
(
void
const
*
,
serializer
*
sink
)
const
{
serialize_nullptr
(
sink
);
}
...
...
@@ -251,7 +251,7 @@ class actor_ptr_tinfo : public util::abstract_uniform_type_info<actor_ptr>
protected:
void
serialize
(
const
void
*
ptr
,
serializer
*
sink
)
const
void
serialize
(
void
const
*
ptr
,
serializer
*
sink
)
const
{
s_serialize
(
*
reinterpret_cast
<
const
actor_ptr
*>
(
ptr
),
sink
,
...
...
@@ -317,7 +317,7 @@ class group_ptr_tinfo : public util::abstract_uniform_type_info<group_ptr>
protected:
void
serialize
(
const
void
*
ptr
,
serializer
*
sink
)
const
void
serialize
(
void
const
*
ptr
,
serializer
*
sink
)
const
{
s_serialize
(
*
reinterpret_cast
<
const
group_ptr
*>
(
ptr
),
sink
,
...
...
@@ -411,7 +411,7 @@ class channel_ptr_tinfo : public util::abstract_uniform_type_info<channel_ptr>
protected:
void
serialize
(
const
void
*
instance
,
serializer
*
sink
)
const
void
serialize
(
void
const
*
instance
,
serializer
*
sink
)
const
{
s_serialize
(
*
reinterpret_cast
<
const
channel_ptr
*>
(
instance
),
sink
,
...
...
@@ -479,7 +479,7 @@ class any_tuple_tinfo : public util::abstract_uniform_type_info<any_tuple>
protected:
void
serialize
(
const
void
*
instance
,
serializer
*
sink
)
const
void
serialize
(
void
const
*
instance
,
serializer
*
sink
)
const
{
s_serialize
(
*
reinterpret_cast
<
const
any_tuple
*>
(
instance
),
sink
,
name
());
}
...
...
@@ -501,7 +501,7 @@ class addr_msg_tinfo : public util::abstract_uniform_type_info<addressed_message
public:
virtual
void
serialize
(
const
void
*
instance
,
serializer
*
sink
)
const
virtual
void
serialize
(
void
const
*
instance
,
serializer
*
sink
)
const
{
const
addressed_message
&
msg
=
*
reinterpret_cast
<
const
addressed_message
*>
(
instance
);
const
any_tuple
&
data
=
msg
.
content
();
...
...
@@ -547,12 +547,68 @@ class addr_msg_tinfo : public util::abstract_uniform_type_info<addressed_message
};
class
process_info_ptr_tinfo
:
public
util
::
abstract_uniform_type_info
<
process_information_ptr
>
{
typedef
process_information_ptr
ptr_type
;
public:
virtual
void
serialize
(
void
const
*
instance
,
serializer
*
sink
)
const
{
auto
&
ptr
=
*
reinterpret_cast
<
ptr_type
const
*>
(
instance
);
if
(
ptr
==
nullptr
)
{
serialize_nullptr
(
sink
);
}
else
{
primitive_variant
ptup
[
2
];
ptup
[
0
]
=
ptr
->
process_id
();
ptup
[
1
]
=
to_string
(
ptr
->
node_id
());
sink
->
begin_object
(
name
());
sink
->
write_tuple
(
2
,
ptup
);
sink
->
end_object
();
}
}
virtual
void
deserialize
(
void
*
instance
,
deserializer
*
source
)
const
{
auto
&
ptrref
=
*
reinterpret_cast
<
ptr_type
*>
(
instance
);
std
::
string
cname
=
source
->
seek_object
();
if
(
cname
!=
name
())
{
if
(
cname
==
nullptr_type_name
)
{
deserialize_nullptr
(
source
);
ptrref
.
reset
();
}
else
{
throw
std
::
logic_error
(
"wrong type name found"
);
}
}
else
{
primitive_variant
ptup
[
2
];
primitive_type
ptypes
[]
=
{
pt_uint32
,
pt_u8string
};
source
->
begin_object
(
cname
);
source
->
read_tuple
(
2
,
ptypes
,
ptup
);
source
->
end_object
();
process_information
::
node_id_type
nid
;
node_id_from_string
(
get
<
std
::
string
>
(
ptup
[
1
]),
nid
);
ptrref
.
reset
(
new
process_information
{
get
<
std
::
uint32_t
>
(
ptup
[
0
]),
nid
});
}
}
};
class
atom_value_tinfo
:
public
util
::
abstract_uniform_type_info
<
atom_value
>
{
public:
virtual
void
serialize
(
const
void
*
instance
,
serializer
*
sink
)
const
virtual
void
serialize
(
void
const
*
instance
,
serializer
*
sink
)
const
{
auto
val
=
reinterpret_cast
<
const
atom_value
*>
(
instance
);
sink
->
begin_object
(
name
());
...
...
@@ -576,7 +632,7 @@ class atom_value_tinfo : public util::abstract_uniform_type_info<atom_value>
class
duration_tinfo
:
public
util
::
abstract_uniform_type_info
<
util
::
duration
>
{
virtual
void
serialize
(
const
void
*
instance
,
serializer
*
sink
)
const
virtual
void
serialize
(
void
const
*
instance
,
serializer
*
sink
)
const
{
auto
val
=
reinterpret_cast
<
const
util
::
duration
*>
(
instance
);
sink
->
begin_object
(
name
());
...
...
@@ -694,6 +750,7 @@ class uniform_type_info_map_helper
insert
(
d
,
new
atom_value_tinfo
,
{
raw_name
<
atom_value
>
()
});
insert
(
d
,
new
addr_msg_tinfo
,
{
raw_name
<
detail
::
addressed_message
>
()
});
insert
(
d
,
new
void_type_tinfo
,
{
raw_name
<
void_type
>
()
});
insert
(
d
,
new
process_info_ptr_tinfo
,
{
raw_name
<
process_information_ptr
>
()});
insert
<
float
>
(
d
);
insert
<
double
>
(
d
);
/*
...
...
unit_testing/main.cpp
View file @
9e34fdf9
...
...
@@ -175,8 +175,8 @@ int main(int argc, char** argv)
},
on
(
"run_ping"
,
arg_match
)
>>
[
&
](
std
::
string
const
&
num_pings
)
{
//
auto ping_actor = spawn<detached>(ping, std::stoi(num_pings));
auto
ping_actor
=
spawn_event_based_ping
(
std
::
stoi
(
num_pings
));
auto
ping_actor
=
spawn
<
detached
>
(
ping
,
std
::
stoi
(
num_pings
));
//
auto ping_actor = spawn_event_based_ping(std::stoi(num_pings));
std
::
uint16_t
port
=
4242
;
bool
success
=
false
;
do
...
...
unit_testing/test__remote_actor.cpp
View file @
9e34fdf9
...
...
@@ -26,7 +26,8 @@ void client_part(std::vector<string_pair> const& args)
}
auto
port
=
static_cast
<
std
::
uint16_t
>
(
std
::
stoi
(
i
->
second
));
auto
ping_actor
=
remote_actor
(
"localhost"
,
port
);
spawn_event_based_pong
(
ping_actor
);
//spawn_event_based_pong(ping_actor);
spawn
<
detached
>
(
pong
,
ping_actor
);
await_all_others_done
();
}
...
...
unit_testing/test__uniform_type.cpp
View file @
9e34fdf9
...
...
@@ -81,12 +81,13 @@ size_t test__uniform_type()
"float"
,
"double"
,
// floating points
"@0"
,
// cppa::util::void_type
// default announced cppa types
"@atom"
,
// cppa::atom_value
"@<>"
,
// cppa::any_tuple
"@msg"
,
// cppa::message
"@actor"
,
// cppa::actor_ptr
"@group"
,
// cppa::group_ptr
"@channel"
,
// cppa::channel_ptr
"@atom"
,
// cppa::atom_value
"@<>"
,
// cppa::any_tuple
"@msg"
,
// cppa::message
"@actor"
,
// cppa::actor_ptr
"@group"
,
// cppa::group_ptr
"@channel"
,
// cppa::channel_ptr
"@process_info"
,
// cppa::intrusive_ptr<cppa::process_information>
"cppa::util::duration"
};
// holds the type names we see at runtime
...
...
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