Closed xiaoyawei closed 6 months ago
I am pretty sure you are right, it seems to me that when MDB_NOTLS
is enabled the transaction is not stored in a particular thread. Rust prevents us from touching the content of transaction (thanks !Sync
) and therefore I am pretty sure that it is safe.
Hey @xiaoyawei 👋
I will be working on that in a PR. Thanks to your emails, we can make the cursors implement Send
.
@Kerollmops That sounds great! My apologies for missing your previous comment but glad this idea can implemented, thanks!
With similar reasoning that
RoTxn
can be moved among threads whenMDB_NOTLS
flag is on, my understanding it that the correspondingRoCursor
andRoIter
(and other readonly iterators like range iterators) can be moved among threads as well, and hereby can implementSend
.By looking at the source code of
lmdb
, looks like cursors is actually a field of a transaction, and since different threads can access to the same db with the transaction pointer not simultaneously, they are also able to use a specific cursor in that transaction for data access.I could be mistaken but would love to hear about opinions from
heed
maintainers. Thanks!