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 append for memory region #109

Closed
my-vegetable-has-exploded opened this issue Aug 13, 2023 · 3 comments · Fixed by #114
Closed

support append for memory region #109

my-vegetable-has-exploded opened this issue Aug 13, 2023 · 3 comments · Fixed by #114

Comments

@my-vegetable-has-exploded
Copy link
Contributor

async-rdma memory region need to use with lock_utilities::MappedRwLockReadGuard.

lmr.as_mut_slice().write(&[1_u8; 8])

I want to append(this can be done by wrapping with std::io::cursor) some bytes to mr to avoid useless copy.

But we can't build a cursor with (MappedRwLockReadGuard), like

    let cursor = std::io::Cursor::new(lmr.as_mut_slice());
	cursor.write(&[1_u8; 8])?;

so, i think we can consider providing a MappedRwLockWriteGuard<Cursor<&mut [u8]>>.

If needed, i can open a pr to add it.

@GTwhy
Copy link
Collaborator

GTwhy commented Aug 16, 2023

Hi @my-vegetable-has-exploded , lmr.as_mut_slice() will return a MappedRwLockWriteGuard but not a MappedRwLockReadGuard. Do You mean the cursor you get by std::io::Cursor::new(lmr.as_mut_slice()) has a type of Cursor<MappedRwLockWriteGuard<&mut [u8]>>, which is not able to write, so you want to add an API to return a MappedRwLockWriteGuard<Cursor<&mut [u8]>>?

@my-vegetable-has-exploded
Copy link
Contributor Author

yes
In this way, we can provide a convenient way for users to append to lmr without having to manage the cursor themselves.

@GTwhy
Copy link
Collaborator

GTwhy commented Aug 17, 2023

@my-vegetable-has-exploded OK,welcome to open the PR!

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 a pull request may close this issue.

2 participants