Skip to content

Commit b621567

Browse files
committed
feat: improved performance; version 1.0.3;
1 parent 1158940 commit b621567

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ jPowerShell2 is a fork of [jPowerShell](https://github.com/profesorfalken/jPower
77

88
## 💻 Installation
99

10-
To install jPowerShell you can add the dependecy to your software project management tool: https://search.maven.org/artifact/io.github.autocomplete1/jPowerShell2/1.0.2/jar
10+
To install jPowerShell you can add the dependecy to your software project management tool: https://search.maven.org/artifact/io.github.autocomplete1/jPowerShell2/1.0.3/jar
1111

1212
Maven:
1313
```
1414
<dependency>
1515
<groupId>io.github.autocomplete1</groupId>
1616
<artifactId>jPowerShell2</artifactId>
17-
<version>1.0.2</version>
17+
<version>1.0.3</version>
1818
<scope>compile</scope>
1919
</dependency>
2020
```
2121

2222
Gradle:
2323
```
24-
implementation 'io.github.autocomplete1:jPowerShell2:1.0.2'
24+
implementation 'io.github.autocomplete1:jPowerShell2:1.0.3'
2525
```
2626

2727
Instead, you can direct download the JAR file and add it to your classpath.
28-
https://repo1.maven.org/maven2/io/github/autocomplete1/jPowerShell2/1.0.2/jPowerShell2-1.0.2.jar
28+
https://repo1.maven.org/maven2/io/github/autocomplete1/jPowerShell2/1.0.3/jPowerShell2-1.0.3.jar
2929

3030
## ⚡️ Usage
3131

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
group = 'io.github.autocomplete1'
9-
version = '1.0.2'
9+
version = '1.0.3'
1010
description = 'Simple Java API to interact with PowerShell console'
1111
java.sourceCompatibility = JavaVersion.VERSION_1_8
1212

src/main/java/io/github/autocomplete1/PowerShellCommandProcessor.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ private void readData(StringBuilder powerShellOutput) throws IOException {
105105
private boolean startReading() throws IOException, InterruptedException {
106106
//If the reader is not ready, gives it some milliseconds
107107
while (!this.outputReader.ready()) {
108-
Thread.sleep(this.waitPause);
108+
synchronized (this) {
109+
wait(this.waitPause);
110+
}
109111
if (this.closed) {
110112
return false;
111113
}
@@ -118,12 +120,16 @@ private boolean canContinueReading() throws IOException, InterruptedException {
118120
//If the reader is not ready, gives it some milliseconds
119121
//It is important to do that, because the ready method guarantees that the readline will not be blocking
120122
if (!this.outputReader.ready()) {
121-
Thread.sleep(this.waitPause);
123+
synchronized (this) {
124+
wait(this.waitPause);
125+
}
122126
}
123127

124128
//If not ready yet, wait a moment to make sure it is finished
125129
if (!this.outputReader.ready()) {
126-
Thread.sleep(50);
130+
synchronized (this) {
131+
wait(50);
132+
}
127133
}
128134

129135
return this.outputReader.ready();

0 commit comments

Comments
 (0)