-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3120 from 1c-syntax/feature/named-pools
Вынос тяжелых parallelStream в отдельный пул потоков, больше именованных пулов
- Loading branch information
Showing
7 changed files
with
109 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...java/com/github/_1c_syntax/bsl/languageserver/utils/NamedForkJoinWorkerThreadFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* This file is a part of BSL Language Server. | ||
* | ||
* Copyright (c) 2018-2023 | ||
* Alexey Sosnoviy <labotamy@gmail.com>, Nikita Fedkin <nixel2007@gmail.com> and contributors | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
* | ||
* BSL Language Server is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3.0 of the License, or (at your option) any later version. | ||
* | ||
* BSL Language Server is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with BSL Language Server. | ||
*/ | ||
package com.github._1c_syntax.bsl.languageserver.utils; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.concurrent.ForkJoinPool; | ||
import java.util.concurrent.ForkJoinWorkerThread; | ||
import java.util.concurrent.atomic.AtomicLong; | ||
|
||
/** | ||
* Фабрика тредов для ForkJoinPool, автоматически добаляющая префикс к имени треда. | ||
*/ | ||
@RequiredArgsConstructor | ||
public class NamedForkJoinWorkerThreadFactory implements ForkJoinPool.ForkJoinWorkerThreadFactory { | ||
|
||
private static final AtomicLong index = new AtomicLong(); | ||
|
||
/** | ||
* Префикс для добавления к имени треда. | ||
*/ | ||
private final String prefix; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public ForkJoinWorkerThread newThread(ForkJoinPool pool) { | ||
var worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); | ||
worker.setName(prefix + index.incrementAndGet()); | ||
return worker; | ||
} | ||
} |