Skip to content
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

Support new spawn #13

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open

Support new spawn #13

wants to merge 31 commits into from

Conversation

joii2020
Copy link
Contributor

@joii2020 joii2020 commented Sep 26, 2024

The simulator uses multithreading to simulate spawn, and each spawn will create a new thread.
After this change, need to use the matching ckb-std to use it in the CKB contract.

Modify

  • Support spawn (multithreading)
  • Add testcase
  • Add CI

@joii2020 joii2020 changed the title [WIP] Support new spawn Support new spawn Sep 29, 2024
src/global_data.rs Outdated Show resolved Hide resolved
PROCESS_CONTEXT_ID.with(|f| f.borrow().clone())
}

pub fn inherited_fds(&self) -> Vec<Fd> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

return by reference.


pub fn wait(&self) {
let (lock, cvar) = &*self.data;
let mut event = lock.lock().unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This name "event" is inconsistent: see notify.

src/spawn.rs Outdated
0
}

fn read(&self, fd: Fd, buf: *mut c_void, length: *mut usize) -> c_int {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If 100 bytes of data are written from one end of the pipe and the other end performs the following actions:

  1. Reads 30 bytes
  2. Reads 40 bytes
  3. Reads 30 bytes

The simulator is unable to handle this correctly.

}
}
impl TxID {
fn next(&mut self) -> Self {

Choose a reason for hiding this comment

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

Why do you modify the original data here, but clone a copy of the data as the return value at the same time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In many places, the next step is HashMap::insert. This way, the return is more convenient to use.

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.

3 participants