-
Notifications
You must be signed in to change notification settings - Fork 30
Change Dumb executor to TLS-based one [ECR-3204] #917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e08ade3
c2142ba
d0b609f
fc3af96
adc7c2a
6990205
effa1c5
68e87cf
5ba4597
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,38 +18,31 @@ extern crate java_bindings; | |
extern crate lazy_static; | ||
|
||
use integration_tests::executor::{ | ||
check_detached, check_nested_attach, test_concurrent_threads, test_serialized_threads, | ||
test_single_thread, | ||
test_concurrent_threads, test_serialized_threads, test_single_thread, | ||
}; | ||
use integration_tests::vm::create_vm_for_tests; | ||
use java_bindings::jni::JavaVM; | ||
use java_bindings::DumbExecutor; | ||
use java_bindings::Executor; | ||
|
||
use std::sync::Arc; | ||
|
||
lazy_static! { | ||
pub static ref VM: Arc<JavaVM> = create_vm_for_tests(); | ||
pub static ref EXECUTOR: DumbExecutor = DumbExecutor::new(VM.clone()); | ||
pub static ref EXECUTOR: Executor = Executor::new(VM.clone()); | ||
} | ||
|
||
#[test] | ||
fn single_thread() { | ||
test_single_thread(&*EXECUTOR); | ||
test_single_thread(EXECUTOR.clone()); | ||
} | ||
|
||
#[test] | ||
fn serialized_threads() { | ||
test_serialized_threads(&*EXECUTOR); | ||
test_serialized_threads(EXECUTOR.clone()); | ||
} | ||
|
||
#[test] | ||
fn concurrent_threads() { | ||
const THREAD_NUM: usize = 8; | ||
test_concurrent_threads(&*EXECUTOR, THREAD_NUM) | ||
} | ||
|
||
#[test] | ||
fn nested_attach() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we shall keep it because it verifies the executor implementation allowing recursive |
||
check_nested_attach(&VM, &*EXECUTOR); | ||
check_detached(&VM); | ||
test_concurrent_threads(EXECUTOR.clone(), THREAD_NUM) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
extern crate integration_tests; | ||
extern crate java_bindings; | ||
#[macro_use] | ||
extern crate lazy_static; | ||
|
||
use integration_tests::executor::check_nested_attach; | ||
use integration_tests::vm::create_vm_for_tests; | ||
use java_bindings::jni::JavaVM; | ||
use java_bindings::Executor; | ||
|
||
use std::sync::Arc; | ||
use std::thread::spawn; | ||
|
||
lazy_static! { | ||
pub static ref VM: Arc<JavaVM> = create_vm_for_tests(); | ||
pub static ref EXECUTOR: Executor = Executor::new(VM.clone()); | ||
} | ||
|
||
/// Checks if nested attaches are working properly and threads detach themselves | ||
/// on exit. | ||
#[test] | ||
fn nested_attach() { | ||
assert_eq!(VM.threads_attached(), 0); | ||
let thread = spawn(|| { | ||
assert_eq!(VM.threads_attached(), 0); | ||
check_nested_attach(&VM, EXECUTOR.clone()); | ||
assert_eq!(VM.threads_attached(), 1); | ||
}); | ||
thread.join().unwrap(); | ||
assert_eq!(VM.threads_attached(), 0); | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not single with the guys below in the same file 🙃
I think we can leave it as is, but please inspect these tests to see if they need to be updated or extended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least
nested_attach
cannot reliably live in the same source file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it can, but it will be unable to check if the thread is detached correctly after the outer-most scope is finished. Other tests a totally fine to live together.