|
1 | 1 | use crate::abi::GCThreadTLS;
|
2 | 2 |
|
3 | 3 | use crate::api::RubyMutator;
|
| 4 | +use crate::gc_thread::RubyGCThreadJoinHandle; |
4 | 5 | use crate::{mmtk, upcalls, Ruby};
|
5 | 6 | use mmtk::memory_manager;
|
6 | 7 | use mmtk::scheduler::*;
|
@@ -31,36 +32,36 @@ impl Collection<Ruby> for VMCollection {
|
31 | 32 | (upcalls().block_for_gc)(tls);
|
32 | 33 | }
|
33 | 34 |
|
34 |
| - fn spawn_gc_thread(_tls: VMThread, ctx: GCThreadContext<Ruby>) { |
35 |
| - match ctx { |
36 |
| - GCThreadContext::Worker(mut worker) => { |
37 |
| - thread::Builder::new() |
38 |
| - .name("MMTk Worker Thread".to_string()) |
39 |
| - .spawn(move || { |
40 |
| - let ordinal = worker.ordinal; |
41 |
| - debug!( |
42 |
| - "Hello! This is MMTk Worker Thread running! ordinal: {}", |
43 |
| - ordinal |
44 |
| - ); |
45 |
| - crate::register_gc_thread(thread::current().id()); |
46 |
| - let ptr_worker = &mut *worker as *mut GCWorker<Ruby>; |
47 |
| - let gc_thread_tls = |
48 |
| - Box::into_raw(Box::new(GCThreadTLS::for_worker(ptr_worker))); |
49 |
| - (upcalls().init_gc_worker_thread)(gc_thread_tls); |
50 |
| - memory_manager::start_worker( |
51 |
| - mmtk(), |
52 |
| - GCThreadTLS::to_vwt(gc_thread_tls), |
53 |
| - worker, |
54 |
| - ); |
55 |
| - debug!( |
56 |
| - "An MMTk Worker Thread is quitting. Good bye! ordinal: {}", |
57 |
| - ordinal |
58 |
| - ); |
59 |
| - crate::unregister_gc_thread(thread::current().id()); |
60 |
| - }) |
61 |
| - .unwrap(); |
62 |
| - } |
63 |
| - } |
| 35 | + fn spawn_gc_thread(_tls: VMThread, ctx: GCThreadContext<Ruby>) -> RubyGCThreadJoinHandle { |
| 36 | + let rust_join_handle = match ctx { |
| 37 | + GCThreadContext::Worker(mut worker) => thread::Builder::new() |
| 38 | + .name("MMTk Worker Thread".to_string()) |
| 39 | + .spawn(move || { |
| 40 | + let ordinal = worker.ordinal; |
| 41 | + debug!( |
| 42 | + "Hello! This is MMTk Worker Thread running! ordinal: {}", |
| 43 | + ordinal |
| 44 | + ); |
| 45 | + crate::register_gc_thread(thread::current().id()); |
| 46 | + let ptr_worker = &mut *worker as *mut GCWorker<Ruby>; |
| 47 | + let gc_thread_tls = |
| 48 | + Box::into_raw(Box::new(GCThreadTLS::for_worker(ptr_worker))); |
| 49 | + (upcalls().init_gc_worker_thread)(gc_thread_tls); |
| 50 | + memory_manager::start_worker( |
| 51 | + mmtk(), |
| 52 | + GCThreadTLS::to_vwt(gc_thread_tls), |
| 53 | + worker, |
| 54 | + ); |
| 55 | + debug!( |
| 56 | + "An MMTk Worker Thread is quitting. Good bye! ordinal: {}", |
| 57 | + ordinal |
| 58 | + ); |
| 59 | + crate::unregister_gc_thread(thread::current().id()); |
| 60 | + }) |
| 61 | + .unwrap(), |
| 62 | + }; |
| 63 | + |
| 64 | + RubyGCThreadJoinHandle::new(rust_join_handle) |
64 | 65 | }
|
65 | 66 |
|
66 | 67 | fn vm_live_bytes() -> usize {
|
|
0 commit comments