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
275ce111
Commit
275ce111
authored
Jul 09, 2012
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check arguments of receive_response
parent
e833d791
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
8 deletions
+20
-8
cppa/cppa.hpp
cppa/cppa.hpp
+20
-8
No files found.
cppa/cppa.hpp
View file @
275ce111
...
@@ -454,7 +454,7 @@ send(const intrusive_ptr<C>& whom, Args&&... what) {
...
@@ -454,7 +454,7 @@ send(const intrusive_ptr<C>& whom, Args&&... what) {
}
}
#ifndef CPPA_DOCUMENTATION
#ifndef CPPA_DOCUMENTATION
typedef
message_id_t
unspecified_handl
e
;
typedef
message_id_t
message_futur
e
;
#endif // CPPA_DOCUMENTATION
#endif // CPPA_DOCUMENTATION
/**
/**
...
@@ -468,7 +468,7 @@ typedef message_id_t unspecified_handle;
...
@@ -468,7 +468,7 @@ typedef message_id_t unspecified_handle;
* @throws std::invalid_argument if <tt>whom == nullptr</tt>
* @throws std::invalid_argument if <tt>whom == nullptr</tt>
*/
*/
template
<
typename
...
Args
>
template
<
typename
...
Args
>
inline
unspecified_handl
e
sync_send
(
const
actor_ptr
&
whom
,
Args
&&
...
what
)
{
inline
message_futur
e
sync_send
(
const
actor_ptr
&
whom
,
Args
&&
...
what
)
{
static_assert
(
sizeof
...(
Args
)
>
0
,
"no message to send"
);
static_assert
(
sizeof
...(
Args
)
>
0
,
"no message to send"
);
if
(
whom
)
{
if
(
whom
)
{
return
self
->
send_sync_message
(
return
self
->
send_sync_message
(
...
@@ -479,8 +479,8 @@ inline unspecified_handle sync_send(const actor_ptr& whom, Args&&... what) {
...
@@ -479,8 +479,8 @@ inline unspecified_handle sync_send(const actor_ptr& whom, Args&&... what) {
}
}
struct
receive_response_helper
{
struct
receive_response_helper
{
unspecified_handl
e
m_handle
;
message_futur
e
m_handle
;
inline
receive_response_helper
(
unspecified_handl
e
handle
)
inline
receive_response_helper
(
message_futur
e
handle
)
:
m_handle
(
handle
)
{
}
:
m_handle
(
handle
)
{
}
template
<
typename
...
Expression
>
template
<
typename
...
Expression
>
inline
void
operator
()(
Expression
&&
...
mexpr
)
const
{
inline
void
operator
()(
Expression
&&
...
mexpr
)
const
{
...
@@ -490,16 +490,28 @@ struct receive_response_helper {
...
@@ -490,16 +490,28 @@ struct receive_response_helper {
if
(
bhvr
.
timeout
().
valid
()
==
false
||
bhvr
.
timeout
().
is_zero
())
{
if
(
bhvr
.
timeout
().
valid
()
==
false
||
bhvr
.
timeout
().
is_zero
())
{
throw
std
::
invalid_argument
(
"specified timeout is invalid or zero"
);
throw
std
::
invalid_argument
(
"specified timeout is invalid or zero"
);
}
}
else
if
(
!
m_handle
.
valid
()
||
!
m_handle
.
is_response
())
{
throw
std
::
logic_error
(
"handle does not point to a response"
);
}
else
if
(
!
self
->
awaits
(
m_handle
))
{
throw
std
::
logic_error
(
"response already received"
);
}
self
->
dequeue_response
(
bhvr
,
m_handle
);
}
}
};
};
inline
receive_response_helper
receive_response
(
unspecified_handle
handle
)
{
/**
* @brief Receives a synchronous response message.
* @param handle A future for a synchronous response.
* @throws std::invalid_argument if given behavior does not has a valid
* timeout definition
* @throws std::logic_error if @p handle is not valid or if the actor
* already received the response for @p handle
*/
inline
receive_response_helper
receive_response
(
message_future
handle
)
{
return
{
handle
};
return
{
handle
};
}
}
/**
/**
* @brief Sends a message to the sender of the last received message.
* @brief Sends a message to the sender of the last received message.
* @param what Message elements.
* @param what Message elements.
...
...
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