Skip to content

Move some vm fields to an Arc-wrapped struct#1933

Merged
coolreader18 merged 3 commits into
masterfrom
coolreader18/arc-vm-state
May 22, 2020
Merged

Move some vm fields to an Arc-wrapped struct#1933
coolreader18 merged 3 commits into
masterfrom
coolreader18/arc-vm-state

Conversation

@coolreader18

Copy link
Copy Markdown
Member

In preparation for threading; we want to keep some properties of the vm consistent across threads, so I'm moving the ones that should be into an Arc.

@coolreader18 coolreader18 force-pushed the coolreader18/arc-vm-state branch from 27e5163 to 5f93f83 Compare May 17, 2020 05:44
@coolreader18 coolreader18 marked this pull request as ready for review May 17, 2020 05:44
Comment thread vm/src/vm.rs
pub struct PyGlobalState {
pub settings: PySettings,
pub stdlib_inits: HashMap<String, stdlib::StdlibInitFunc>,
pub frozen: HashMap<String, bytecode::FrozenModule>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the frozen modules should be a global static? This should not change between VMs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but it's possible that someone would want to inject a frozen module into one VM to wrap their API or something, but want to use another vm for something different. I've done that myself in another project that uses RustPython.

@coolreader18 coolreader18 merged commit 6ed172d into master May 22, 2020
@coolreader18 coolreader18 deleted the coolreader18/arc-vm-state branch May 22, 2020 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants