forked from corda/corda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENT-3000 Start pooling classpath scanning and related fixes (corda#4664)
* Start pooling classpath scanning Quickly patch synchronisation of attachment class loader cache. Needs a revisit but more complicated due to DJVM. Annotate away for DJVM Take ClassGraph utils into their own file so we can exclude for DJVM Clean up a little * Daemonize the threads * Seems to be some concurrency problems with use of ClassGraph. Using a mutex for now to work around.
- Loading branch information
Showing
9 changed files
with
30 additions
and
19 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
core/src/main/kotlin/net/corda/core/internal/ClassGraphUtils.kt
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,19 @@ | ||
@file:DeleteForDJVM | ||
|
||
package net.corda.core.internal | ||
|
||
import co.paralleluniverse.strands.concurrent.ReentrantLock | ||
import io.github.classgraph.ClassGraph | ||
import io.github.classgraph.ScanResult | ||
import net.corda.core.DeleteForDJVM | ||
import kotlin.concurrent.withLock | ||
|
||
private val pooledScanMutex = ReentrantLock() | ||
|
||
/** | ||
* Use this rather than the built in implementation of [scan] on [ClassGraph]. The built in implementation of [scan] creates | ||
* a thread pool every time resulting in too many threads. This one uses a mutex to restrict concurrency. | ||
*/ | ||
fun ClassGraph.pooledScan(): ScanResult { | ||
return pooledScanMutex.withLock { this@pooledScan.scan() } | ||
} |
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
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