gpt4 book ai didi

leveldb - leveldb 快照的线程安全

转载 作者:行者123 更新时间:2023-12-04 12:12:47 27 4
gpt4 key购买 nike

读取快照是 leveldb 的完全线程安全操作吗?

具体来说,
一个线程读取 leveldb 数据库的快照,而另一个线程在同一数据库上读/写是否线程安全?那么另一个线程可能在读取时同时关闭数据库或删除快照呢?

最佳答案

根据文档:

A database may only be opened by one process at a time. The leveldb implementation acquires a lock from the operating system to prevent misuse. Within a single process, the same leveldb::DB object may be safely shared by multiple concurrent threads. I.e., different threads may write into or fetch iterators or call Get on the same database without any external synchronization (the leveldb implementation will automatically do the required synchronization). However other objects (like Iterator and WriteBatch) may require external synchronization. If two threads share such an object, they must protect access to it using their own locking protocol. More details are available in the public header files.



https://github.com/google/leveldb/blob/master/doc/index.md#concurrency

关于leveldb - leveldb 快照的线程安全,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23188037/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com