pjtatlow/jammdb

Async version

ozgrakkurt opened this issue · 2 comments

Hey!

Would adding an option to have an async version via something like maybe_async make sense?

I want to implement this since I want to use this database but I want to use it in an async context and doing tokio::spawn_blocking or similar for every db call doesn't feel right.

Hey @ozgrakkurt, this isn't a bad idea, but it only makes sense for writes.

All reads are done to a memory map, so there is nothing to do asyncronously. When we try to read from a memory address, if that page isn't in memory we will just get a page fault and the OS will load that in. There's no way to "asyncify" that.

Writes are done directly to the file though, so the commit method on the transaction could be async. It shouldn't be difficult, I just haven't gotten around to doing this yet. Are you interested in giving it a try?

Thanks for the explanation! I decided to just go with sync API so it is fine for me for now.