aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/installer
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-05 02:42:02 +0900
committernsfisis <nsfisis@gmail.com>2026-06-05 02:42:02 +0900
commit9a25fcfc82b72f60facd381786ca5490acca032c (patch)
treeb34b36c19f14d57d160b8e4235a8040011bdec60 /crates/shirabe/src/installer
parent886ee829cb191745167dca369045acd3125e5714 (diff)
downloadphp-shirabe-9a25fcfc82b72f60facd381786ca5490acca032c.tar.gz
php-shirabe-9a25fcfc82b72f60facd381786ca5490acca032c.tar.zst
php-shirabe-9a25fcfc82b72f60facd381786ca5490acca032c.zip
feat(dependency-resolver): share operations via Rc, drop clone_box
OperationInterface::clone_box (a todo!() trait-object clone stub) is removed in favor of Rc<dyn OperationInterface> shared ownership. All its methods are &self, so operations are immutable value objects that Rc can share; pushing the same operation into multiple lists (installer's install/uninstall splits) becomes a cheap Rc clone instead of clone_box. Box<dyn OperationInterface> is replaced with Rc<dyn ...> across Transaction (and its Lock/LocalRepo wrappers), Installer, PackageEvent, InstallationManager and EventDispatcher; Box::new operation constructions become Rc::new. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/installer')
-rw-r--r--crates/shirabe/src/installer/installation_manager.rs18
-rw-r--r--crates/shirabe/src/installer/package_event.rs10
2 files changed, 14 insertions, 14 deletions
diff --git a/crates/shirabe/src/installer/installation_manager.rs b/crates/shirabe/src/installer/installation_manager.rs
index 8275b41..2fc77d9 100644
--- a/crates/shirabe/src/installer/installation_manager.rs
+++ b/crates/shirabe/src/installer/installation_manager.rs
@@ -169,7 +169,7 @@ impl InstallationManager {
pub fn execute(
&mut self,
repo: &mut dyn InstalledRepositoryInterface,
- operations: Vec<Box<dyn OperationInterface>>,
+ operations: Vec<std::rc::Rc<dyn OperationInterface>>,
dev_mode: bool,
run_scripts: bool,
download_only: bool,
@@ -200,8 +200,8 @@ impl InstallationManager {
let result: Result<()> = (|| -> Result<()> {
// execute operations in batches to make sure download-modifying-plugins are installed
// before the other packages get downloaded
- let mut batches: Vec<IndexMap<i64, Box<dyn OperationInterface>>> = vec![];
- let mut batch: IndexMap<i64, Box<dyn OperationInterface>> = IndexMap::new();
+ let mut batches: Vec<IndexMap<i64, std::rc::Rc<dyn OperationInterface>>> = vec![];
+ let mut batch: IndexMap<i64, std::rc::Rc<dyn OperationInterface>> = IndexMap::new();
for (index, operation) in operations.into_iter().enumerate() {
let index = index as i64;
let package: Option<PackageInterfaceHandle> =
@@ -287,7 +287,7 @@ impl InstallationManager {
async fn download_and_execute_batch(
&mut self,
repo: &mut dyn InstalledRepositoryInterface,
- operations: IndexMap<i64, Box<dyn OperationInterface>>,
+ operations: IndexMap<i64, std::rc::Rc<dyn OperationInterface>>,
cleanup_promises: &mut IndexMap<
i64,
Box<
@@ -298,7 +298,7 @@ impl InstallationManager {
dev_mode: bool,
run_scripts: bool,
download_only: bool,
- all_operations: Vec<Box<dyn OperationInterface>>,
+ all_operations: Vec<std::rc::Rc<dyn OperationInterface>>,
) -> Result<()> {
for (index, operation) in &operations {
let op_type = operation.get_operation_type();
@@ -359,8 +359,8 @@ impl InstallationManager {
// execute operations in batches to make sure every plugin is installed in the
// right order and activated before the packages depending on it are installed
- let mut batches: Vec<IndexMap<i64, Box<dyn OperationInterface>>> = vec![];
- let mut batch: IndexMap<i64, Box<dyn OperationInterface>> = IndexMap::new();
+ let mut batches: Vec<IndexMap<i64, std::rc::Rc<dyn OperationInterface>>> = vec![];
+ let mut batch: IndexMap<i64, std::rc::Rc<dyn OperationInterface>> = IndexMap::new();
for (index, operation) in operations {
let package: Option<PackageInterfaceHandle> =
if let Some(update) = operation.as_update_operation() {
@@ -411,7 +411,7 @@ impl InstallationManager {
async fn execute_batch(
&mut self,
repo: &mut dyn InstalledRepositoryInterface,
- operations: IndexMap<i64, Box<dyn OperationInterface>>,
+ operations: IndexMap<i64, std::rc::Rc<dyn OperationInterface>>,
cleanup_promises: &IndexMap<
i64,
Box<
@@ -421,7 +421,7 @@ impl InstallationManager {
>,
dev_mode: bool,
run_scripts: bool,
- all_operations: &[Box<dyn OperationInterface>],
+ all_operations: &[std::rc::Rc<dyn OperationInterface>],
) -> Result<()> {
let mut post_exec_callbacks: Vec<Box<dyn Fn()>> = vec![];
diff --git a/crates/shirabe/src/installer/package_event.rs b/crates/shirabe/src/installer/package_event.rs
index 342732d..17f9113 100644
--- a/crates/shirabe/src/installer/package_event.rs
+++ b/crates/shirabe/src/installer/package_event.rs
@@ -14,8 +14,8 @@ pub struct PackageEvent {
io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>,
dev_mode: bool,
local_repo: Box<dyn RepositoryInterface>,
- operations: Vec<Box<dyn OperationInterface>>,
- operation: Box<dyn OperationInterface>,
+ operations: Vec<std::rc::Rc<dyn OperationInterface>>,
+ operation: std::rc::Rc<dyn OperationInterface>,
}
impl PackageEvent {
@@ -25,8 +25,8 @@ impl PackageEvent {
io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>,
dev_mode: bool,
local_repo: Box<dyn RepositoryInterface>,
- operations: Vec<Box<dyn OperationInterface>>,
- operation: Box<dyn OperationInterface>,
+ operations: Vec<std::rc::Rc<dyn OperationInterface>>,
+ operation: std::rc::Rc<dyn OperationInterface>,
) -> Self {
Self {
inner: Event::new(event_name, vec![], IndexMap::new()),
@@ -59,7 +59,7 @@ impl PackageEvent {
self.local_repo.as_ref()
}
- pub fn get_operations(&self) -> &Vec<Box<dyn OperationInterface>> {
+ pub fn get_operations(&self) -> &Vec<std::rc::Rc<dyn OperationInterface>> {
&self.operations
}