📚 Phase 12.5 最適化戦略 & Phase 15 セルフホスティング計画
Phase 12.5: MIR15最適化戦略 - コンパイラ丸投げ作戦 - optimization-strategy.txt: 詳細戦略(MIR側は軽量、コンパイラに丸投げ) - implementation-examples.md: 具体的な実装例 - debug-safety-comparison.md: 現在のDebugBox vs ChatGPT5提案の比較分析 Phase 15: Nyashセルフホスティング - 究極の目標 - self-hosting-plan.txt: 内蔵Craneliftによる実現計画 - technical-details.md: CompilerBox設計とブートストラップ手順 - README.md: セルフホスティングのビジョン 重要な知見: - LLVM統合完了済み(Phase 11)だが依存が重すぎる - Craneliftが現実的な選択肢(3-5MB vs LLVM 50-100MB) - 「コンパイラもBox、すべてがBox」の夢へ MASTERロードマップ更新済み
This commit is contained in:
@ -85,6 +85,7 @@ pub mod gc_config_box;
|
||||
pub mod aot_config_box;
|
||||
pub mod aot_compiler_box;
|
||||
pub mod task_group_box;
|
||||
pub mod token_box;
|
||||
|
||||
// Web専用Box群(ブラウザ環境でのみ利用可能)
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
@ -124,6 +125,7 @@ pub use jit_hostcall_registry_box::JitHostcallRegistryBox;
|
||||
pub use aot_config_box::AotConfigBox;
|
||||
pub use aot_compiler_box::AotCompilerBox;
|
||||
pub use task_group_box::TaskGroupBox;
|
||||
pub use token_box::TokenBox;
|
||||
|
||||
// EguiBoxの再エクスポート(非WASM環境のみ)
|
||||
#[cfg(all(feature = "gui", not(target_arch = "wasm32")))]
|
||||
|
||||
@ -4,7 +4,7 @@ use std::sync::{Arc, Mutex};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct TaskGroupInner {
|
||||
pub(super) strong: Mutex<Vec<crate::boxes::future::FutureBox>>,
|
||||
pub strong: Mutex<Vec<crate::boxes::future::FutureBox>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
38
src/boxes/token_box.rs
Normal file
38
src/boxes/token_box.rs
Normal file
@ -0,0 +1,38 @@
|
||||
use crate::box_trait::{NyashBox, BoxCore, BoxBase, StringBox, BoolBox};
|
||||
use std::any::Any;
|
||||
|
||||
/// Cancellation token as a Box for structured concurrency
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TokenBox {
|
||||
base: BoxBase,
|
||||
token: crate::runtime::scheduler::CancellationToken,
|
||||
}
|
||||
|
||||
impl TokenBox {
|
||||
pub fn new() -> Self { Self { base: BoxBase::new(), token: crate::runtime::scheduler::CancellationToken::new() } }
|
||||
pub fn from_token(token: crate::runtime::scheduler::CancellationToken) -> Self { Self { base: BoxBase::new(), token } }
|
||||
pub fn cancel(&self) { self.token.cancel(); }
|
||||
pub fn is_cancelled(&self) -> bool { self.token.is_cancelled() }
|
||||
pub fn inner(&self) -> crate::runtime::scheduler::CancellationToken { self.token.clone() }
|
||||
}
|
||||
|
||||
impl BoxCore for TokenBox {
|
||||
fn box_id(&self) -> u64 { self.base.id }
|
||||
fn parent_type_id(&self) -> Option<std::any::TypeId> { None }
|
||||
fn fmt_box(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "CancellationToken(cancelled={})", self.token.is_cancelled())
|
||||
}
|
||||
fn as_any(&self) -> &dyn Any { self }
|
||||
fn as_any_mut(&mut self) -> &mut dyn Any { self }
|
||||
}
|
||||
|
||||
impl NyashBox for TokenBox {
|
||||
fn to_string_box(&self) -> StringBox { StringBox::new(format!("CancellationToken(cancelled={})", self.token.is_cancelled())) }
|
||||
fn equals(&self, other: &dyn NyashBox) -> BoolBox {
|
||||
if let Some(o) = other.as_any().downcast_ref::<TokenBox>() {
|
||||
BoolBox::new(self.is_cancelled() == o.is_cancelled())
|
||||
} else { BoolBox::new(false) }
|
||||
}
|
||||
fn clone_box(&self) -> Box<dyn NyashBox> { Box::new(self.clone()) }
|
||||
fn share_box(&self) -> Box<dyn NyashBox> { Box::new(self.clone()) }
|
||||
}
|
||||
Reference in New Issue
Block a user