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

Allow for thread safe FixedBuf handles #185

Open
Nehliin opened this issue Nov 26, 2022 · 3 comments
Open

Allow for thread safe FixedBuf handles #185

Nehliin opened this issue Nov 26, 2022 · 3 comments
Labels

Comments

@Nehliin
Copy link
Contributor

Nehliin commented Nov 26, 2022

With the introduction of Fixed buffers I was curious if it would be possible to also expose thread safe handles to those buffers? I.e supporting operations on different threads (and runtimes) but still utilizing the same buffer pool. The use case I have in mind for example is having a separate disk-io thread which would be distinct from the thread reading data from a socket. It would be neat if both could share the same buffer pool by propagating the handles from the socket thread to the disk thread and then use write_fixed there.

After discussions on discord it seems like at a minimum register_buffers and unregister_buffers needs to be exposed publicly for it to be possible for end users to create their own buffer registries.

@Nehliin
Copy link
Contributor Author

Nehliin commented Nov 26, 2022

I realize now that another problem is that all the io objects like TcpStream etc only accepts the FixedBuf handle making it impossible to use a custom registry that would with thread safe handles.

@mzabaluev
Copy link
Contributor

The reference counting mechanics would need to be redone with something like Arc<Mutex<FixedBuffers>>, which would cause unnecessary overhead in the single threaded case.

I think it should be possible to have thread-safe fixed buffer collections alongside the current ones. For operations, it should be possible to generalize with a marker trait.

@Nehliin
Copy link
Contributor Author

Nehliin commented Nov 29, 2022

Yes! I do not want us to replace the existing ones. Just make the operations more flexible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants