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
93e72f80
Commit
93e72f80
authored
9 years ago
by
Anton Piccardo-Selg
Browse files
Options
Downloads
Patches
Plain Diff
Refs #15288 Change mutex for ThreadScheduler
parent
39f32529
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Framework/Kernel/inc/MantidKernel/ThreadScheduler.h
+2
-2
2 additions, 2 deletions
Framework/Kernel/inc/MantidKernel/ThreadScheduler.h
Framework/Kernel/inc/MantidKernel/ThreadSchedulerMutexes.h
+6
-11
6 additions, 11 deletions
Framework/Kernel/inc/MantidKernel/ThreadSchedulerMutexes.h
with
8 additions
and
13 deletions
Framework/Kernel/inc/MantidKernel/ThreadScheduler.h
+
2
−
2
View file @
93e72f80
...
...
@@ -150,7 +150,7 @@ public:
//-------------------------------------------------------------------------------
/// @return true if the queue is empty
bool
empty
()
override
{
Mutex
::
ScopedLock
_lock
(
m_queueLock
);
Kernel
::
LockGuardMutex
_lock
(
m_queueLock
);
return
m_queue
.
empty
();
}
...
...
@@ -255,7 +255,7 @@ public:
//-------------------------------------------------------------------------------
/// @return true if the queue is empty
bool
empty
()
override
{
Mutex
::
ScopedLock
_lock
(
m_queueLock
);
Kernel
::
LockGuardMutex
_lock
(
m_queueLock
);
return
m_map
.
empty
();
}
...
...
This diff is collapsed.
Click to expand it.
Framework/Kernel/inc/MantidKernel/ThreadSchedulerMutexes.h
+
6
−
11
View file @
93e72f80
...
...
@@ -33,12 +33,11 @@ public:
//-------------------------------------------------------------------------------
void
push
(
Task
*
newTask
)
override
{
// Cache the total cost
m_queueLock
.
lock
(
);
Kernel
::
LockGuardMutex
lock
(
m_queueLock
);
m_cost
+=
newTask
->
cost
();
boost
::
shared_ptr
<
Mutex
>
mut
=
newTask
->
getMutex
();
m_supermap
[
mut
].
emplace
(
newTask
->
cost
(),
newTask
);
m_queueLock
.
unlock
();
}
//-------------------------------------------------------------------------------
...
...
@@ -47,7 +46,7 @@ public:
Task
*
temp
=
NULL
;
m_queueLock
.
lock
(
);
Kernel
::
LockGuardMutex
lock
(
m_queueLock
);
// Check the size within the same locking block; otherwise the size may
// change before you get the next item.
if
(
m_supermap
.
size
()
>
0
)
{
...
...
@@ -101,7 +100,6 @@ public:
m_mutexes
.
insert
(
mut
);
}
m_queueLock
.
unlock
();
return
temp
;
}
...
...
@@ -115,30 +113,28 @@ public:
UNUSED_ARG
(
threadnum
);
boost
::
shared_ptr
<
Mutex
>
mut
=
task
->
getMutex
();
if
(
mut
)
{
m_queueLock
.
lock
(
);
Kernel
::
LockGuardMutex
lock
(
m_queueLock
);
// We take this mutex off the list of used ones.
m_mutexes
.
erase
(
mut
);
m_queueLock
.
unlock
();
}
}
//-------------------------------------------------------------------------------
size_t
size
()
override
{
m_queueLock
.
lock
(
);
Kernel
::
LockGuardMutex
lock
(
m_queueLock
);
// Add up the sizes of all contained maps.
size_t
total
=
0
;
SuperMap
::
iterator
it
=
m_supermap
.
begin
();
SuperMap
::
iterator
it_end
=
m_supermap
.
end
();
for
(;
it
!=
it_end
;
it
++
)
total
+=
it
->
second
.
size
();
m_queueLock
.
unlock
();
return
total
;
}
//-------------------------------------------------------------------------------
/// @return true if the queue is empty
bool
empty
()
override
{
Mutex
::
ScopedLock
_
lock
(
m_queueLock
);
Kernel
::
LockGuardMutex
lock
(
m_queueLock
);
SuperMap
::
iterator
it
=
m_supermap
.
begin
();
SuperMap
::
iterator
it_end
=
m_supermap
.
end
();
for
(;
it
!=
it_end
;
it
++
)
...
...
@@ -149,7 +145,7 @@ public:
//-------------------------------------------------------------------------------
void
clear
()
override
{
m_queueLock
.
lock
(
);
Kernel
::
LockGuardMutex
lock
(
m_queueLock
);
// Empty out the queue and delete the pointers!
SuperMap
::
iterator
it
=
m_supermap
.
begin
();
...
...
@@ -165,7 +161,6 @@ public:
m_supermap
.
clear
();
m_cost
=
0
;
m_costExecuted
=
0
;
m_queueLock
.
unlock
();
}
protected
:
...
...
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