Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
cc7f9186
Commit
cc7f9186
authored
7 years ago
by
Roman Tolchenov
Committed by
Peterson, Peter
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Re #19764. Additional bools to avoid blocking.
parent
e14cbd07
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Framework/API/test/AsynchronousTest.h
+19
-7
19 additions, 7 deletions
Framework/API/test/AsynchronousTest.h
with
19 additions
and
7 deletions
Framework/API/test/AsynchronousTest.h
+
19
−
7
View file @
cc7f9186
...
...
@@ -20,9 +20,12 @@ using namespace std;
namespace
{
constexpr
int
NO_OF_LOOPS
=
10
;
bool
synchronise
=
false
;
std
::
condition_variable
condition1
;
std
::
condition_variable
condition2
;
std
::
mutex
mtx
;
bool
testStarted
=
false
;
bool
execStarted
=
false
;
}
class
AsyncAlgorithm
:
public
Algorithm
{
...
...
@@ -50,10 +53,13 @@ public:
void
exec
()
override
{
if
(
synchronise
)
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
mtx
);
condition1
.
wait
(
lock
);
execStarted
=
true
;
condition1
.
notify_all
();
if
(
!
testStarted
)
{
condition2
.
wait
(
lock
);
}
}
Poco
::
Thread
*
thr
=
Poco
::
Thread
::
current
();
condition2
.
notify_all
();
for
(
int
i
=
0
;
i
<
NO_OF_LOOPS
;
i
++
)
{
result
=
i
;
if
(
thr
)
...
...
@@ -66,8 +72,6 @@ public:
}
int
result
;
bool
synchronise
=
false
;
protected
:
bool
throw_exception
;
};
...
...
@@ -154,18 +158,26 @@ public:
}
void
testCancelGroupWS
()
{
synchronise
=
true
;
testStarted
=
false
;
execStarted
=
false
;
WorkspaceGroup_sptr
groupWS
=
makeGroupWorkspace
();
AsyncAlgorithm
alg
;
alg
.
synchronise
=
true
;
setupTest
(
alg
);
alg
.
setPropertyValue
(
"InputWorkspace"
,
"groupWS"
);
Poco
::
ActiveResult
<
bool
>
result
=
alg
.
executeAsync
();
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
mtx
);
condition1
.
notify_all
();
condition2
.
wait
(
lock
);
if
(
!
execStarted
)
{
condition1
.
wait
(
lock
);
}
}
alg
.
cancel
();
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
mtx
);
testStarted
=
true
;
}
condition2
.
notify_all
();
result
.
wait
();
generalChecks
(
alg
,
false
,
true
,
false
,
true
);
// The parent algorithm is not executed directly, so the result remains 0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment