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
Shervin Nourbakhsh
cameo
Commits
17e9513c
Commit
17e9513c
authored
Mar 05, 2020
by
legoc
Browse files
Reimplemented cancel of Instance.waitFor()
parent
79b101f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/cameo/Application.cpp
View file @
17e9513c
...
...
@@ -33,13 +33,14 @@
#include "impl/HandlerImpl.h"
#include "impl/StreamSocketImpl.h"
#include "impl/RequestSocketImpl.h"
#include "PortEvent.h"
#include "ProtoType.h"
#include "PublisherEvent.h"
#include "ResultEvent.h"
#include "Server.h"
#include "StarterServerException.h"
#include "StatusEvent.h"
#include "PublisherEvent.h"
#include "ResultEvent.h"
#include "PortEvent.h"
#include "CancelEvent.h"
using
namespace
std
;
...
...
@@ -448,6 +449,8 @@ Instance::Instance(Server * server) :
m_initialState
(
UNKNOWN
),
m_lastState
(
UNKNOWN
),
m_hasResult
(
false
)
{
m_waiting
.
reset
(
new
GenericWaitingImpl
(
bind
(
&
Instance
::
cancelWaitFor
,
this
)));
}
Instance
::~
Instance
()
{
...
...
@@ -565,7 +568,7 @@ State Instance::waitFor(int states, const std::string& eventName, StateHandlerTy
// Waits for a new incoming status
unique_ptr
<
Event
>
event
=
popEvent
(
blocking
);
// The
socket is canceled or the
non-blocking call returns a null message.
// The non-blocking call returns a null message.
if
(
event
.
get
()
==
nullptr
)
{
return
m_lastState
;
}
...
...
@@ -595,25 +598,27 @@ State Instance::waitFor(int states, const std::string& eventName, StateHandlerTy
if
((
states
&
m_pastStates
)
!=
0
)
{
return
m_lastState
;
}
}
else
{
}
else
{
if
(
ResultEvent
*
result
=
dynamic_cast
<
ResultEvent
*>
(
event
.
get
()))
{
m_hasResult
=
true
;
m_resultData
=
result
->
getData
();
}
else
if
(
PublisherEvent
*
publisher
=
dynamic_cast
<
PublisherEvent
*>
(
event
.
get
()))
{
}
else
if
(
PublisherEvent
*
publisher
=
dynamic_cast
<
PublisherEvent
*>
(
event
.
get
()))
{
if
(
publisher
->
getPublisherName
()
==
eventName
)
{
break
;
}
}
else
if
(
PortEvent
*
port
=
dynamic_cast
<
PortEvent
*>
(
event
.
get
()))
{
}
else
if
(
PortEvent
*
port
=
dynamic_cast
<
PortEvent
*>
(
event
.
get
()))
{
if
(
port
->
getPortName
()
==
eventName
)
{
break
;
}
}
else
if
(
CancelEvent
*
cancel
=
dynamic_cast
<
CancelEvent
*>
(
event
.
get
()))
{
break
;
}
}
}
}
...
...
src/cameo/Application.h
View file @
17e9513c
...
...
@@ -255,6 +255,7 @@ private:
State
m_lastState
;
bool
m_hasResult
;
std
::
string
m_resultData
;
std
::
unique_ptr
<
WaitingImpl
>
m_waiting
;
};
///////////////////////////////////////////////////////////////////////////
...
...
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