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
b7e99c51
Commit
b7e99c51
authored
Oct 29, 2016
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt to middleman actor behavior accepting URIs
parent
8c140ab5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
17 deletions
+21
-17
examples/remoting/distributed_calculator.cpp
examples/remoting/distributed_calculator.cpp
+16
-13
libcaf_io/test/basp.cpp
libcaf_io/test/basp.cpp
+4
-2
libcaf_io/test/unpublish.cpp
libcaf_io/test/unpublish.cpp
+1
-2
No files found.
examples/remoting/distributed_calculator.cpp
View file @
b7e99c51
...
@@ -93,8 +93,7 @@ struct state {
...
@@ -93,8 +93,7 @@ struct state {
behavior
unconnected
(
stateful_actor
<
state
>*
);
behavior
unconnected
(
stateful_actor
<
state
>*
);
// prototype definition for transition to `connecting` with Host and Port
// prototype definition for transition to `connecting` with Host and Port
void
connecting
(
stateful_actor
<
state
>*
,
void
connecting
(
stateful_actor
<
state
>*
,
io
::
uri
);
const
std
::
string
&
host
,
uint16_t
port
);
// prototype definition for transition to `running` with Calculator
// prototype definition for transition to `running` with Calculator
behavior
running
(
stateful_actor
<
state
>*
,
actor
calculator
);
behavior
running
(
stateful_actor
<
state
>*
,
actor
calculator
);
...
@@ -121,27 +120,28 @@ behavior unconnected(stateful_actor<state>* self) {
...
@@ -121,27 +120,28 @@ behavior unconnected(stateful_actor<state>* self) {
self
->
state
.
tasks
.
emplace_back
(
task
{
op
,
x
,
y
});
self
->
state
.
tasks
.
emplace_back
(
task
{
op
,
x
,
y
});
},
},
[
=
](
connect_atom
,
const
std
::
string
&
host
,
uint16_t
port
)
{
[
=
](
connect_atom
,
const
std
::
string
&
host
,
uint16_t
port
)
{
connecting
(
self
,
host
,
port
);
auto
u
=
io
::
uri
::
make
(
"tcp://"
+
host
+
std
::
to_string
(
port
));
if
(
!
u
)
throw
sec
::
invalid_argument
;
connecting
(
self
,
std
::
move
(
*
u
));
}
}
};
};
}
}
void
connecting
(
stateful_actor
<
state
>*
self
,
void
connecting
(
stateful_actor
<
state
>*
self
,
io
::
uri
u
)
{
const
std
::
string
&
host
,
uint16_t
port
)
{
// make sure we are not pointing to an old server
// make sure we are not pointing to an old server
self
->
state
.
current_server
=
nullptr
;
self
->
state
.
current_server
=
nullptr
;
// use request().await() to suspend regular behavior until MM responded
// use request().await() to suspend regular behavior until MM responded
auto
mm
=
self
->
system
().
middleman
().
actor_handle
();
auto
mm
=
self
->
system
().
middleman
().
actor_handle
();
self
->
request
(
mm
,
infinite
,
connect_atom
::
value
,
host
,
port
).
await
(
self
->
request
(
mm
,
infinite
,
connect_atom
::
value
,
u
).
await
(
[
=
](
const
node_id
&
,
strong_actor_ptr
serv
,
const
std
::
set
<
std
::
string
>&
ifs
)
{
[
=
](
const
node_id
&
,
strong_actor_ptr
serv
,
const
std
::
set
<
std
::
string
>&
ifs
)
{
if
(
!
serv
)
{
if
(
!
serv
)
{
aout
(
self
)
<<
"*** no server found at
\"
"
<<
host
<<
"
\"
:"
aout
(
self
)
<<
"*** no server found at
\"
"
<<
u
<<
endl
;
<<
port
<<
endl
;
return
;
return
;
}
}
if
(
!
ifs
.
empty
())
{
if
(
!
ifs
.
empty
())
{
aout
(
self
)
<<
"*** typed actor found at
\"
"
<<
host
<<
"
\"
:"
aout
(
self
)
<<
"*** typed actor found at
\"
"
<<
u
<<
port
<<
", but expected an untyped actor "
<<
endl
;
<<
", but expected an untyped actor "
<<
endl
;
return
;
return
;
}
}
aout
(
self
)
<<
"*** successfully connected to server"
<<
endl
;
aout
(
self
)
<<
"*** successfully connected to server"
<<
endl
;
...
@@ -151,8 +151,8 @@ void connecting(stateful_actor<state>* self,
...
@@ -151,8 +151,8 @@ void connecting(stateful_actor<state>* self,
self
->
become
(
running
(
self
,
hdl
));
self
->
become
(
running
(
self
,
hdl
));
},
},
[
=
](
const
error
&
err
)
{
[
=
](
const
error
&
err
)
{
aout
(
self
)
<<
"*** cannot connect to
\"
"
<<
host
<<
"
\"
:"
aout
(
self
)
<<
"*** cannot connect to
\"
"
<<
u
<<
port
<<
" => "
<<
self
->
system
().
render
(
err
)
<<
endl
;
<<
" => "
<<
self
->
system
().
render
(
err
)
<<
endl
;
self
->
become
(
unconnected
(
self
));
self
->
become
(
unconnected
(
self
));
}
}
);
);
...
@@ -183,7 +183,10 @@ behavior running(stateful_actor<state>* self, actor calculator) {
...
@@ -183,7 +183,10 @@ behavior running(stateful_actor<state>* self, actor calculator) {
send_task
(
task
{
op
,
x
,
y
});
send_task
(
task
{
op
,
x
,
y
});
},
},
[
=
](
connect_atom
,
const
std
::
string
&
host
,
uint16_t
port
)
{
[
=
](
connect_atom
,
const
std
::
string
&
host
,
uint16_t
port
)
{
connecting
(
self
,
host
,
port
);
auto
u
=
io
::
uri
::
make
(
"tcp://"
+
host
+
std
::
to_string
(
port
));
if
(
!
u
)
throw
sec
::
invalid_argument
;
connecting
(
self
,
std
::
move
(
*
u
));
}
}
};
};
}
}
...
...
libcaf_io/test/basp.cpp
View file @
b7e99c51
...
@@ -575,13 +575,15 @@ CAF_TEST(publish_and_connect) {
...
@@ -575,13 +575,15 @@ CAF_TEST(publish_and_connect) {
CAF_TEST
(
remote_actor_and_send
)
{
CAF_TEST
(
remote_actor_and_send
)
{
constexpr
const
char
*
lo
=
"localhost"
;
constexpr
const
char
*
lo
=
"localhost"
;
constexpr
uint16_t
port
=
4242
;
auto
u
=
uri
::
make
(
"tcp://"
+
std
::
string
(
lo
)
+
":"
+
std
::
to_string
(
port
));
CAF_REQUIRE
(
u
);
CAF_MESSAGE
(
"self: "
<<
to_string
(
self
()
->
address
()));
CAF_MESSAGE
(
"self: "
<<
to_string
(
self
()
->
address
()));
mpx
()
->
provide_scribe
(
lo
,
4242
,
jupiter
().
connection
);
mpx
()
->
provide_scribe
(
lo
,
4242
,
jupiter
().
connection
);
CAF_REQUIRE
(
mpx
()
->
has_pending_scribe
(
lo
,
4242
));
CAF_REQUIRE
(
mpx
()
->
has_pending_scribe
(
lo
,
4242
));
auto
mm1
=
system
.
middleman
().
actor_handle
();
auto
mm1
=
system
.
middleman
().
actor_handle
();
actor
result
;
actor
result
;
auto
f
=
self
()
->
request
(
mm1
,
infinite
,
auto
f
=
self
()
->
request
(
mm1
,
infinite
,
connect_atom
::
value
,
*
u
);
connect_atom
::
value
,
lo
,
uint16_t
{
4242
});
// wait until BASP broker has received and processed the connect message
// wait until BASP broker has received and processed the connect message
while
(
!
aut
()
->
valid
(
jupiter
().
connection
))
while
(
!
aut
()
->
valid
(
jupiter
().
connection
))
mpx
()
->
exec_runnable
();
mpx
()
->
exec_runnable
();
...
...
libcaf_io/test/unpublish.cpp
View file @
b7e99c51
...
@@ -73,9 +73,8 @@ struct fixture {
...
@@ -73,9 +73,8 @@ struct fixture {
actor
result
;
actor
result
;
scoped_actor
self
{
system
,
true
};
scoped_actor
self
{
system
,
true
};
auto
host
=
std
::
string
(
u
.
host
().
first
,
u
.
host
().
second
);
auto
host
=
std
::
string
(
u
.
host
().
first
,
u
.
host
().
second
);
auto
port
=
u
.
port_as_int
();
self
->
request
(
system
.
middleman
().
actor_handle
(),
infinite
,
self
->
request
(
system
.
middleman
().
actor_handle
(),
infinite
,
connect_atom
::
value
,
host
,
port
).
receive
(
connect_atom
::
value
,
u
).
receive
(
[
&
](
node_id
&
,
strong_actor_ptr
&
res
,
std
::
set
<
std
::
string
>&
xs
)
{
[
&
](
node_id
&
,
strong_actor_ptr
&
res
,
std
::
set
<
std
::
string
>&
xs
)
{
CAF_REQUIRE
(
xs
.
empty
());
CAF_REQUIRE
(
xs
.
empty
());
if
(
res
)
if
(
res
)
...
...
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