@@ -330,8 +330,8 @@ private void generateContinuous(TestInfo info) {
330
330
pw .println (" " + r + "[] gr;" );
331
331
pw .println ();
332
332
333
- pw .println (" public " + className + "(ForkedTestConfig config, ExecutorService pool ) {" );
334
- pw .println (" super(config, pool );" );
333
+ pw .println (" public " + className + "(ForkedTestConfig config) {" );
334
+ pw .println (" super(config);" );
335
335
pw .println (" }" );
336
336
pw .println ();
337
337
@@ -351,33 +351,28 @@ private void generateContinuous(TestInfo info) {
351
351
352
352
for (int a = 0 ; a < actorsCount ; a ++) {
353
353
ExecutableElement el = info .getActors ().get (a );
354
- pw .println (" Future<?> a" + a + " = pool.submit( new Callable<Object> () { public Object call () {" );
354
+ pw .println (" VoidThread a" + a + " = new VoidThread () { protected void internalRun () {" );
355
355
pw .print (" " );
356
356
emitMethod (pw , el , (isStateItself ? "s." : "t." ) + el .getSimpleName (), "s" , "r" , false );
357
357
pw .println (";" );
358
- pw .println (" return null;" );
359
- pw .println (" }});" );
358
+ pw .println (" }};" );
359
+ }
360
+
361
+ for (int a = 0 ; a < actorsCount ; a ++) {
362
+ pw .println (" a" + a + ".start();" );
360
363
}
361
364
362
365
for (int a = 0 ; a < actorsCount ; a ++) {
363
- pw .println (" try {" );
364
- pw .println (" a" + a + ".get();" );
365
- pw .println (" } catch (ExecutionException e) {" );
366
- pw .println (" throw e.getCause();" );
366
+ pw .println (" a" + a + ".join();" );
367
+ pw .println (" if (a" + a + ".throwable() != null) {" );
368
+ pw .println (" throw a" + a + ".throwable();" );
367
369
pw .println (" }" );
368
370
}
369
371
370
372
if (info .getArbiter () != null ) {
371
- pw .println (" try {" );
372
- pw .println (" pool.submit(new Callable<Object>() { public Object call() {" );
373
- pw .print (" " );
373
+ pw .print (" " );
374
374
emitMethod (pw , info .getArbiter (), (isStateItself ? "s." : "t." ) + info .getArbiter ().getSimpleName (), "s" , "r" , false );
375
375
pw .println (";" );
376
- pw .println (" return null;" );
377
- pw .println (" }}).get();" );
378
- pw .println (" } catch (ExecutionException e) {" );
379
- pw .println (" throw e.getCause();" );
380
- pw .println (" }" );
381
376
}
382
377
pw .println (" counter.record(r);" );
383
378
pw .println (" }" );
@@ -404,7 +399,7 @@ private void generateContinuous(TestInfo info) {
404
399
405
400
for (int a = 0 ; a < actorsCount ; a ++) {
406
401
ExecutableElement el = info .getActors ().get (a );
407
- pw .println (" Future<Long> a" + a + " = pool.submit( new Callable<Long> () { public Long call () {" );
402
+ pw .println (" LongThread a" + a + " = new LongThread () { public long internalRun () {" );
408
403
pw .println (" long a1 = AllocProfileSupport.getAllocatedBytes();" );
409
404
pw .println (" for (int c = 0; c < size; c++) {" );
410
405
pw .print (" " );
@@ -413,32 +408,26 @@ private void generateContinuous(TestInfo info) {
413
408
pw .println (" }" );
414
409
pw .println (" long a2 = AllocProfileSupport.getAllocatedBytes();" );
415
410
pw .println (" return a2 - a1;" );
416
- pw .println (" }});" );
411
+ pw .println (" }};" );
412
+ }
413
+
414
+ for (int a = 0 ; a < actorsCount ; a ++) {
415
+ pw .println (" a" + a + ".start();" );
417
416
}
418
417
419
418
for (int a = 0 ; a < actorsCount ; a ++) {
420
419
pw .println (" try {" );
421
- pw .println (" cnts[0] += a" + a + ".get ();" );
422
- pw .println (" } catch (Throwable e) { " );
423
- pw .println (" // Should not happen, checked in API check " );
420
+ pw .println (" a" + a + ".join ();" );
421
+ pw .println (" cnts[0] += a" + a + ".result(); " );
422
+ pw .println (" } catch (InterruptedException e) { " );
424
423
pw .println (" }" );
425
424
}
426
425
427
426
if (info .getArbiter () != null ) {
428
- pw .println (" try {" );
429
- pw .println (" long a = pool.submit(new Callable<Long>() { public Long call() {" );
430
- pw .println (" long a1 = AllocProfileSupport.getAllocatedBytes();" );
431
- pw .println (" for (int c = 0; c < size; c++) {" );
432
- pw .print (" " );
427
+ pw .println (" for (int c = 0; c < size; c++) {" );
428
+ pw .print (" " );
433
429
emitMethod (pw , info .getArbiter (), (isStateItself ? "ls[c]." : "t." ) + info .getArbiter ().getSimpleName (), "ls[c]" , "lr[c]" , false );
434
430
pw .println (";" );
435
- pw .println (" }" );
436
- pw .println (" long a2 = AllocProfileSupport.getAllocatedBytes();" );
437
- pw .println (" return a2 - a1;" );
438
- pw .println (" }}).get();" );
439
- pw .println (" cnts[0] += a;" );
440
- pw .println (" } catch (Throwable e) {" );
441
- pw .println (" // Should not happen, checked in API check" );
442
431
pw .println (" }" );
443
432
}
444
433
@@ -454,7 +443,7 @@ private void generateContinuous(TestInfo info) {
454
443
pw .println ();
455
444
456
445
pw .println (" @Override" );
457
- pw .println (" public ArrayList<Future<Counter< " + r + "> >> internalRun() {" );
446
+ pw .println (" public ArrayList<CounterThread< " + r + ">> internalRun() {" );
458
447
if (!isStateItself ) {
459
448
pw .println (" test = new " + t + "();" );
460
449
}
@@ -468,13 +457,17 @@ private void generateContinuous(TestInfo info) {
468
457
pw .println ();
469
458
pw .println (" control.isStopped = false;" );
470
459
pw .println ();
471
- pw .println (" ArrayList<Future<Counter< " + r + ">>> results = new ArrayList<>(" + actorsCount + ");" );
460
+ pw .println (" ArrayList<CounterThread< " + r + ">> threads = new ArrayList<>(" + actorsCount + ");" );
472
461
for (ExecutableElement a : info .getActors ()) {
473
- pw .println (" results .add(pool.submit( new Callable<Counter< " + r + ">> () { public Counter<" + r + "> call () {" );
462
+ pw .println (" threads .add(new CounterThread< " + r + ">() { public Counter<" + r + "> internalRun () {" );
474
463
pw .println (" return " + TASK_LOOP_PREFIX + a .getSimpleName () + "();" );
475
- pw .println (" }})) ;" );
464
+ pw .println (" }});" );
476
465
}
477
466
pw .println ();
467
+ pw .println (" for (CounterThread t : threads) {" );
468
+ pw .println (" t.start();" );
469
+ pw .println (" }" );
470
+ pw .println ();
478
471
pw .println (" if (config.time > 0) {" );
479
472
pw .println (" try {" );
480
473
pw .println (" TimeUnit.MILLISECONDS.sleep(config.time);" );
@@ -484,7 +477,7 @@ private void generateContinuous(TestInfo info) {
484
477
pw .println ();
485
478
pw .println (" control.isStopped = true;" );
486
479
pw .println ();
487
- pw .println (" return results ;" );
480
+ pw .println (" return threads ;" );
488
481
pw .println (" }" );
489
482
pw .println ();
490
483
@@ -771,8 +764,8 @@ private void generateTermination(TestInfo info) {
771
764
pw .println ("public class " + generatedName + " extends Runner<" + generatedName + ".Outcome> {" );
772
765
pw .println ();
773
766
774
- pw .println (" public " + generatedName + "(ForkedTestConfig config, ExecutorService pool ) {" );
775
- pw .println (" super(config, pool );" );
767
+ pw .println (" public " + generatedName + "(ForkedTestConfig config) {" );
768
+ pw .println (" super(config);" );
776
769
pw .println (" }" );
777
770
pw .println ();
778
771
@@ -798,7 +791,7 @@ private void generateTermination(TestInfo info) {
798
791
pw .println (" }" );
799
792
pw .println ();
800
793
pw .println (" @Override" );
801
- pw .println (" public ArrayList<Future<Counter< Outcome> >> internalRun() {" );
794
+ pw .println (" public ArrayList<CounterThread< Outcome>> internalRun() {" );
802
795
pw .println (" throw new UnsupportedOperationException();" );
803
796
pw .println (" }" );
804
797
pw .println ();
@@ -949,13 +942,12 @@ private void emitMethodTermination(PrintWriter pw, ExecutableElement el, String
949
942
private void printImports (PrintWriter pw , TestInfo info ) {
950
943
Class <?>[] imports = new Class <?>[] {
951
944
ArrayList .class , Arrays .class ,
952
- ExecutorService . class , Future . class , TimeUnit .class ,
945
+ TimeUnit .class ,
953
946
ForkedTestConfig .class , TestResult .class ,
954
947
Runner .class , WorkerSync .class , Counter .class ,
955
- ExecutionException .class ,
956
- Callable .class ,
957
948
AffinitySupport .class , AllocProfileSupport .class ,
958
949
FootprintEstimator .class ,
950
+ VoidThread .class , LongThread .class , CounterThread .class
959
951
};
960
952
961
953
for (Class <?> c : imports ) {
0 commit comments