Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Cameo
cameo
Commits
031e73a1
Commit
031e73a1
authored
Aug 31, 2017
by
legoc
Browse files
Enabled to define more than one requester on the same responder in one
Application instance.
parent
e5bc2ea7
Changes
6
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
031e73a1
0.1.2
-----
* Enabled to define more than one requester on the same responder in one Application instance.
0.1.0
-----
...
...
configure.ac
View file @
031e73a1
...
...
@@ -4,8 +4,8 @@
#
# -----------------------------------------------------------------------------
AC_INIT(cameo-api-cpp, 0.1.
1
-dev)
LIBRARY_VERSION=0:1:
1
AC_INIT(cameo-api-cpp, 0.1.
2
-dev)
LIBRARY_VERSION=0:1:
2
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_SRCDIR(src/cameo/Application.cpp)
...
...
src/cameo/Application.cpp
View file @
031e73a1
...
...
@@ -1048,8 +1048,8 @@ bool Responder::hasEnded() const {
///////////////////////////////////////////////////////////////////////////
// Requester
Requester
::
Requester
(
const
application
::
This
*
application
,
const
std
::
string
&
url
,
int
requesterPort
,
int
responderPort
,
const
std
::
string
&
name
,
int
responderId
)
:
m_impl
(
new
RequesterImpl
(
application
,
url
,
requesterPort
,
responderPort
,
name
,
responderId
))
{
Requester
::
Requester
(
const
application
::
This
*
application
,
const
std
::
string
&
url
,
int
requesterPort
,
int
responderPort
,
const
std
::
string
&
name
,
int
responderId
,
int
requesterId
)
:
m_impl
(
new
RequesterImpl
(
application
,
url
,
requesterPort
,
responderPort
,
name
,
responderId
,
requesterId
))
{
// Create the waiting here.
m_waiting
.
reset
(
m_impl
->
waiting
());
...
...
@@ -1065,7 +1065,8 @@ std::auto_ptr<Requester> Requester::create(Instance & instance, const std::strin
string
responderEndpoint
=
instance
.
getEndpoint
();
string
responderPortName
=
ResponderImpl
::
RESPONDER_PREFIX
+
name
;
string
requesterPortName
=
RequesterImpl
::
getRequesterPortName
(
name
,
responderId
);
int
requesterId
=
RequesterImpl
::
newRequesterId
();
string
requesterPortName
=
RequesterImpl
::
getRequesterPortName
(
name
,
responderId
,
requesterId
);
string
strRequestType
=
This
::
m_instance
.
m_impl
->
createRequest
(
PROTO_CONNECTPORT
);
string
strRequestData
=
This
::
m_instance
.
m_impl
->
createConnectPortRequest
(
responderId
,
responderPortName
);
...
...
@@ -1104,7 +1105,7 @@ std::auto_ptr<Requester> Requester::create(Instance & instance, const std::strin
throw
RequesterCreationException
(
requestResponse
.
message
());
}
return
auto_ptr
<
Requester
>
(
new
Requester
(
&
This
::
m_instance
,
responderUrl
,
requesterPort
,
responderPort
,
name
,
responderId
));
return
auto_ptr
<
Requester
>
(
new
Requester
(
&
This
::
m_instance
,
responderUrl
,
requesterPort
,
responderPort
,
name
,
responderId
,
requesterId
));
}
const
std
::
string
&
Requester
::
getName
()
const
{
...
...
@@ -1325,6 +1326,7 @@ std::ostream& operator<<(std::ostream& os, const application::Responder& respond
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
application
::
Requester
&
requester
)
{
os
<<
"req."
<<
requester
.
getName
()
<<
"."
<<
requester
.
m_impl
->
m_requesterId
<<
":"
<<
requester
.
m_impl
->
m_application
->
getName
()
<<
"."
<<
requester
.
m_impl
->
m_application
->
getId
()
<<
"@"
<<
requester
.
m_impl
->
m_application
->
getEndpoint
();
...
...
src/cameo/Application.h
View file @
031e73a1
...
...
@@ -439,7 +439,7 @@ public:
void
cancel
();
private:
Requester
(
const
application
::
This
*
application
,
const
std
::
string
&
url
,
int
requesterPort
,
int
responderPort
,
const
std
::
string
&
name
,
int
responderId
);
Requester
(
const
application
::
This
*
application
,
const
std
::
string
&
url
,
int
requesterPort
,
int
responderPort
,
const
std
::
string
&
name
,
int
responderId
,
int
requesterId
);
std
::
auto_ptr
<
RequesterImpl
>
m_impl
;
std
::
auto_ptr
<
WaitingImpl
>
m_waiting
;
...
...
src/cameo/impl/RequesterImpl.cpp
View file @
031e73a1
...
...
@@ -28,12 +28,15 @@ using namespace boost;
namespace
cameo
{
const
std
::
string
RequesterImpl
::
REQUESTER_PREFIX
=
"req."
;
boost
::
mutex
RequesterImpl
::
m_mutex
;
int
RequesterImpl
::
m_requesterCounter
=
0
;
RequesterImpl
::
RequesterImpl
(
const
application
::
This
*
application
,
const
std
::
string
&
url
,
int
requesterPort
,
int
responderPort
,
const
std
::
string
&
name
,
int
responderId
)
:
RequesterImpl
::
RequesterImpl
(
const
application
::
This
*
application
,
const
std
::
string
&
url
,
int
requesterPort
,
int
responderPort
,
const
std
::
string
&
name
,
int
responderId
,
int
requesterId
)
:
m_application
(
application
),
m_requesterPort
(
requesterPort
),
m_name
(
name
),
m_responderId
(
responderId
)
{
m_responderId
(
responderId
),
m_requesterId
(
requesterId
)
{
stringstream
repEndpoint
;
repEndpoint
<<
url
<<
":"
<<
responderPort
;
...
...
@@ -51,10 +54,18 @@ RequesterImpl::~RequesterImpl() {
terminate
();
}
std
::
string
RequesterImpl
::
getRequesterPortName
(
const
std
::
string
&
name
,
int
responderId
)
{
int
RequesterImpl
::
newRequesterId
()
{
boost
::
mutex
::
scoped_lock
lock
(
m_mutex
);
m_requesterCounter
++
;
return
m_requesterCounter
;
}
std
::
string
RequesterImpl
::
getRequesterPortName
(
const
std
::
string
&
name
,
int
responderId
,
int
requesterId
)
{
stringstream
requesterPortName
;
requesterPortName
<<
REQUESTER_PREFIX
<<
name
<<
"."
<<
responderId
;
requesterPortName
<<
REQUESTER_PREFIX
<<
name
<<
"."
<<
responderId
<<
"."
<<
requesterId
;
return
requesterPortName
.
str
();
}
...
...
@@ -185,7 +196,7 @@ void RequesterImpl::terminate() {
if
(
m_requester
.
get
()
!=
0
)
{
m_requester
.
reset
(
0
);
bool
success
=
m_application
->
removePort
(
getRequesterPortName
(
m_name
,
m_responderId
));
bool
success
=
m_application
->
removePort
(
getRequesterPortName
(
m_name
,
m_responderId
,
m_requesterId
));
if
(
!
success
)
{
cerr
<<
"server cannot destroy requester "
<<
m_name
<<
endl
;
}
...
...
src/cameo/impl/RequesterImpl.h
View file @
031e73a1
...
...
@@ -20,7 +20,7 @@
#include <string>
#include <vector>
#include <stdint.h>
#include <boost/thread.hpp>
#include "GenericWaitingImpl.h"
#include "zmq.hpp"
...
...
@@ -33,10 +33,11 @@ namespace application {
class
RequesterImpl
{
public:
RequesterImpl
(
const
application
::
This
*
application
,
const
std
::
string
&
url
,
int
requesterPort
,
int
responderPort
,
const
std
::
string
&
name
,
int
responderId
);
RequesterImpl
(
const
application
::
This
*
application
,
const
std
::
string
&
url
,
int
requesterPort
,
int
responderPort
,
const
std
::
string
&
name
,
int
responderId
,
int
requesterId
);
~
RequesterImpl
();
static
std
::
string
getRequesterPortName
(
const
std
::
string
&
name
,
int
responderId
);
static
int
newRequesterId
();
static
std
::
string
getRequesterPortName
(
const
std
::
string
&
name
,
int
responderId
,
int
requesterId
);
WaitingImpl
*
waiting
();
...
...
@@ -55,9 +56,13 @@ public:
std
::
string
m_responderEndpoint
;
std
::
string
m_name
;
int
m_responderId
;
int
m_requesterId
;
std
::
auto_ptr
<
zmq
::
socket_t
>
m_requester
;
static
const
std
::
string
REQUESTER_PREFIX
;
static
boost
::
mutex
m_mutex
;
static
int
m_requesterCounter
;
};
}
...
...
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