Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
c483c5ca
Commit
c483c5ca
authored
Jul 16, 2024
by
Vladislav Vaintroub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-33627 preparation - tpool fix
Fix tpool to not use maintenance timer for fixed pool size.
parent
59167c56
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
9 deletions
+22
-9
tpool/tpool_generic.cc
tpool/tpool_generic.cc
+22
-9
No files found.
tpool/tpool_generic.cc
View file @
c483c5ca
...
...
@@ -441,7 +441,7 @@ class thread_pool_generic : public thread_pool
disarm
();
}
};
timer_generic
m_maintenance_time
r
;
timer_generic
*
m_maintenance_timer
=
nullpt
r
;
timer
*
create_timer
(
callback_func
func
,
void
*
data
)
override
{
return
new
timer_generic
(
func
,
data
,
this
);
...
...
@@ -751,9 +751,16 @@ bool thread_pool_generic::add_thread()
reset the flag in thread_pool_generic::worker_main in new thread created. The
flag must be reset back in case we fail to create the thread. If this flag is
not reset all future attempt to create thread for this pool would not work as
we would return from here. */
we would return from here.
Do not use this flag for pool of fixed size.
(since they lack maintenence that would rectify the pool size, if it is too small)
*/
if
(
m_min_threads
!=
m_max_threads
)
{
if
(
m_thread_creation_pending
.
test_and_set
())
return
false
;
}
worker_data
*
thread_data
=
m_thread_data_cache
.
get
();
m_active_threads
.
push_back
(
thread_data
);
...
...
@@ -820,13 +827,16 @@ thread_pool_generic::thread_pool_generic(int min_threads, int max_threads) :
m_min_threads
(
min_threads
),
m_max_threads
(
max_threads
),
m_last_thread_count
(),
m_last_activity
(),
m_maintenance_timer
(
thread_pool_generic
::
maintenance_func
,
this
,
nullptr
)
m_last_activity
()
{
set_concurrency
();
// start the timer
m_maintenance_timer
.
set_time
(
0
,
(
int
)
m_timer_interval
.
count
());
if
(
m_min_threads
!=
m_max_threads
)
{
m_maintenance_timer
=
new
timer_generic
(
thread_pool_generic
::
maintenance_func
,
this
,
nullptr
);
m_maintenance_timer
->
set_time
(
0
,
(
int
)
m_timer_interval
.
count
());
}
}
...
...
@@ -933,7 +943,8 @@ void thread_pool_generic::switch_timer(timer_state_t state)
long
long
period
=
(
state
==
timer_state_t
::
OFF
)
?
m_timer_interval
.
count
()
*
10
:
m_timer_interval
.
count
();
m_maintenance_timer
.
set_period
((
int
)
period
);
if
(
m_maintenance_timer
)
m_maintenance_timer
->
set_period
((
int
)
period
);
}
...
...
@@ -951,7 +962,8 @@ thread_pool_generic::~thread_pool_generic()
m_aio
.
reset
();
/* Also stop the maintanence task early. */
m_maintenance_timer
.
disarm
();
if
(
m_maintenance_timer
)
m_maintenance_timer
->
disarm
();
std
::
unique_lock
<
std
::
mutex
>
lk
(
m_mtx
);
m_in_shutdown
=
true
;
...
...
@@ -967,6 +979,7 @@ thread_pool_generic::~thread_pool_generic()
}
lk
.
unlock
();
delete
m_maintenance_timer
;
}
thread_pool
*
create_thread_pool_generic
(
int
min_threads
,
int
max_threads
)
...
...
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