-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Quasar to work with multiple classloaders.
- Loading branch information
Showing
13 changed files
with
415 additions
and
110 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
38 changes: 38 additions & 0 deletions
38
...e/src/classloadertest/java/co.paralleluniverse.fibers.dynamic/DynamicallyLoadedFiber.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,38 @@ | ||
package co.paralleluniverse.fibers.dynamic; | ||
|
||
import co.paralleluniverse.fibers.Fiber; | ||
import co.paralleluniverse.fibers.SuspendExecution; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class DynamicallyLoadedFiber extends Fiber<ArrayList<String>> { | ||
@Override | ||
protected ArrayList<String> run() throws SuspendExecution, InterruptedException { | ||
ArrayList<String> results = new ArrayList<>(); | ||
Test testClass = new Test(); | ||
results.add("a"); | ||
Fiber.park(); | ||
results.add("b"); | ||
testClass.test(results); | ||
results.add("c"); | ||
return results; | ||
} | ||
|
||
private static class Base { | ||
public void baseTest(ArrayList<String> results) throws SuspendExecution { | ||
results.add("base1"); | ||
Fiber.park(); | ||
results.add("base2"); | ||
} | ||
} | ||
|
||
private static class Test extends Base { | ||
public void test(ArrayList<String> results) throws SuspendExecution { | ||
results.add("o1"); | ||
Fiber.park(); | ||
results.add("o2"); | ||
baseTest(results); | ||
results.add("o3"); | ||
} | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
...classloadertest/java/co.paralleluniverse.fibers.dynamic/DynamicallyLoadedSuspendable.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,75 @@ | ||
package co.paralleluniverse.fibers.dynamic; | ||
|
||
import co.paralleluniverse.common.test.TestInterface; | ||
import co.paralleluniverse.common.test.TestInterface2; | ||
import co.paralleluniverse.fibers.Fiber; | ||
import co.paralleluniverse.fibers.SuspendExecution; | ||
import co.paralleluniverse.fibers.Suspendable; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class DynamicallyLoadedSuspendable implements TestInterface { | ||
@Suspendable | ||
public void test(ArrayList<String> results) { | ||
results.add("a"); | ||
TestInterface referencedSuspend = new ReferencedSuspendable(); | ||
TestInterface2 indirectSuspend = new IndirectSuspendable(); | ||
results.add("b"); | ||
try { | ||
results.add("c"); | ||
Fiber.park(); | ||
results.add("d"); | ||
} catch (SuspendExecution ex) { | ||
|
||
} | ||
results.add("e"); | ||
referencedSuspend.test(results); | ||
results.add("f"); | ||
indirectSuspend.test(results, referencedSuspend); | ||
results.add("g"); | ||
while (true) { | ||
results.add("h"); | ||
indirectSuspend.test(results, referencedSuspend); | ||
results.add("i"); | ||
} | ||
} | ||
|
||
private static class BaseSuspendable { | ||
@Suspendable | ||
public void baseTest(ArrayList<String> results) { | ||
try { | ||
results.add("b1"); | ||
Fiber.park(); | ||
results.add("b2"); | ||
} catch (SuspendExecution ex) { | ||
|
||
} | ||
} | ||
} | ||
|
||
private static class ReferencedSuspendable extends BaseSuspendable implements TestInterface { | ||
@Override | ||
@Suspendable | ||
public void test(ArrayList<String> results) { | ||
try { | ||
results.add("d1"); | ||
Fiber.park(); | ||
results.add("d2"); | ||
} catch (SuspendExecution ex) { | ||
|
||
} | ||
baseTest(results); | ||
} | ||
} | ||
|
||
private static class IndirectSuspendable extends BaseSuspendable implements TestInterface2 { | ||
@Override | ||
@Suspendable | ||
public void test(ArrayList<String> results, TestInterface target) { | ||
results.add("o1"); | ||
target.test(results); | ||
results.add("o2"); | ||
baseTest(results); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
quasar-core/src/main/java/co/paralleluniverse/common/test/TestInterface.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,10 @@ | ||
package co.paralleluniverse.common.test; | ||
|
||
import co.paralleluniverse.fibers.Suspendable; | ||
|
||
import java.util.ArrayList; | ||
|
||
public interface TestInterface { | ||
@Suspendable | ||
void test(ArrayList<String> results); | ||
} |
10 changes: 10 additions & 0 deletions
10
quasar-core/src/main/java/co/paralleluniverse/common/test/TestInterface2.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,10 @@ | ||
package co.paralleluniverse.common.test; | ||
|
||
import co.paralleluniverse.fibers.Suspendable; | ||
|
||
import java.util.ArrayList; | ||
|
||
public interface TestInterface2 { | ||
@Suspendable | ||
void test(ArrayList<String> results, TestInterface target); | ||
} |
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
Oops, something went wrong.