Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Nora Puchreiner
Nix
Commits
e682a8e1
Commit
e682a8e1
authored
8 years ago
by
Eelco Dolstra
Browse files
Options
Downloads
Patches
Plain Diff
Fix assertion failure in ThreadPool::enqueue()
parent
d57981ba
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/libutil/thread-pool.cc
+4
-2
4 additions, 2 deletions
src/libutil/thread-pool.cc
src/libutil/thread-pool.hh
+2
-0
2 additions, 0 deletions
src/libutil/thread-pool.hh
with
6 additions
and
2 deletions
src/libutil/thread-pool.cc
+
4
−
2
View file @
e682a8e1
...
@@ -36,7 +36,8 @@ ThreadPool::~ThreadPool()
...
@@ -36,7 +36,8 @@ ThreadPool::~ThreadPool()
void
ThreadPool
::
enqueue
(
const
work_t
&
t
)
void
ThreadPool
::
enqueue
(
const
work_t
&
t
)
{
{
auto
state
(
state_
.
lock
());
auto
state
(
state_
.
lock
());
assert
(
!
state
->
quit
);
if
(
state
->
quit
)
throw
ThreadPoolShutDown
(
"cannot enqueue a work item while the thread pool is shutting down"
);
state
->
left
.
push
(
t
);
state
->
left
.
push
(
t
);
if
(
state
->
left
.
size
()
>
state
->
workers
.
size
()
&&
state
->
workers
.
size
()
<
maxThreads
)
if
(
state
->
left
.
size
()
>
state
->
workers
.
size
()
&&
state
->
workers
.
size
()
<
maxThreads
)
state
->
workers
.
emplace_back
(
&
ThreadPool
::
workerEntry
,
this
);
state
->
workers
.
emplace_back
(
&
ThreadPool
::
workerEntry
,
this
);
...
@@ -84,7 +85,8 @@ void ThreadPool::workerEntry()
...
@@ -84,7 +85,8 @@ void ThreadPool::workerEntry()
}
catch
(
std
::
exception
&
e
)
{
}
catch
(
std
::
exception
&
e
)
{
auto
state
(
state_
.
lock
());
auto
state
(
state_
.
lock
());
if
(
state
->
exception
)
{
if
(
state
->
exception
)
{
if
(
!
dynamic_cast
<
Interrupted
*>
(
&
e
))
if
(
!
dynamic_cast
<
Interrupted
*>
(
&
e
)
&&
!
dynamic_cast
<
ThreadPoolShutDown
*>
(
&
e
))
printMsg
(
lvlError
,
format
(
"error: %s"
)
%
e
.
what
());
printMsg
(
lvlError
,
format
(
"error: %s"
)
%
e
.
what
());
}
else
{
}
else
{
state
->
exception
=
std
::
current_exception
();
state
->
exception
=
std
::
current_exception
();
...
...
This diff is collapsed.
Click to expand it.
src/libutil/thread-pool.hh
+
2
−
0
View file @
e682a8e1
...
@@ -10,6 +10,8 @@
...
@@ -10,6 +10,8 @@
namespace
nix
{
namespace
nix
{
MakeError
(
ThreadPoolShutDown
,
Error
)
/* A simple thread pool that executes a queue of work items
/* A simple thread pool that executes a queue of work items
(lambdas). */
(lambdas). */
class
ThreadPool
class
ThreadPool
...
...
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