Skip to content

Commit f4216dc

Browse files
committed
Remove the references to the read-txn-no-tls feature
1 parent f76bfc6 commit f4216dc

File tree

6 files changed

+64
-48
lines changed

6 files changed

+64
-48
lines changed

heed/src/cookbook.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,9 @@
341341
//!
342342
//! # Advanced Multithreaded Access of Entries
343343
//!
344-
//! LMDB disallow sharing cursors amongs threads. It is only possible to send
345-
//! them between threads when the heed `read-txn-no-tls` feature is enabled.
344+
//! LMDB disallows sharing cursors among threads. It is only possible to send
345+
//! them between threads when the environment has been opened with
346+
//! [`EnvOpenOptions::read_txn_without_tls`] method.
346347
//!
347348
//! Please note that this should not be utilized with an encrypted heed3 database. These
348349
//! types of databases employ an internal cycling buffer for decrypting entries, which

heed/src/databases/database.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,9 @@ impl<KC, DC, C> Database<KC, DC, C> {
378378

379379
/// Returns an iterator over all of the values of a single key.
380380
///
381-
/// You can make this iterator `Send`able between threads by
382-
/// using the `read-txn-no-tls` crate feature.
381+
/// You can make this iterator `Send`able between threads by opening
382+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
383+
/// method.
383384
///
384385
/// ```
385386
/// # use std::fs;
@@ -986,8 +987,9 @@ impl<KC, DC, C> Database<KC, DC, C> {
986987

987988
/// Return an ordered iterator of all key-value pairs in this database.
988989
///
989-
/// You can make this iterator `Send`able between threads by
990-
/// using the `read-txn-no-tls` crate feature.
990+
/// You can make this iterator `Send`able between threads by opening
991+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
992+
/// method.
991993
///
992994
/// ```
993995
/// # use std::fs;
@@ -1087,8 +1089,9 @@ impl<KC, DC, C> Database<KC, DC, C> {
10871089

10881090
/// Return a reverse ordered iterator of all key-value pairs in this database.
10891091
///
1090-
/// You can make this iterator `Send`able between threads by
1091-
/// using the `read-txn-no-tls` crate feature.
1092+
/// You can make this iterator `Send`able between threads by opening
1093+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
1094+
/// method.
10921095
///
10931096
/// ```
10941097
/// # use std::fs;
@@ -1192,8 +1195,9 @@ impl<KC, DC, C> Database<KC, DC, C> {
11921195
///
11931196
/// Comparisons are made by using the comparator `C`.
11941197
///
1195-
/// You can make this iterator `Send`able between threads by
1196-
/// using the `read-txn-no-tls` crate feature.
1198+
/// You can make this iterator `Send`able between threads by opening
1199+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
1200+
/// method.
11971201
///
11981202
/// ```
11991203
/// # use std::fs;
@@ -1364,8 +1368,9 @@ impl<KC, DC, C> Database<KC, DC, C> {
13641368
///
13651369
/// Comparisons are made by using the comparator `C`.
13661370
///
1367-
/// You can make this iterator `Send`able between threads by
1368-
/// using the `read-txn-no-tls` crate feature.
1371+
/// You can make this iterator `Send`able between threads by opening
1372+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
1373+
/// method.
13691374
///
13701375
/// ```
13711376
/// # use std::fs;
@@ -1537,8 +1542,9 @@ impl<KC, DC, C> Database<KC, DC, C> {
15371542
///
15381543
/// Comparisons are made by using the bytes representation of the key.
15391544
///
1540-
/// You can make this iterator `Send`able between threads by
1541-
/// using the `read-txn-no-tls` crate feature.
1545+
/// You can make this iterator `Send`able between threads by opening
1546+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
1547+
/// method.
15421548
///
15431549
/// ```
15441550
/// # use std::fs;
@@ -1669,8 +1675,9 @@ impl<KC, DC, C> Database<KC, DC, C> {
16691675
///
16701676
/// Comparisons are made by using the bytes representation of the key.
16711677
///
1672-
/// You can make this iterator `Send`able between threads by
1673-
/// using the `read-txn-no-tls` crate feature.
1678+
/// You can make this iterator `Send`able between threads by opening
1679+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
1680+
/// method.
16741681
///
16751682
/// ```
16761683
/// # use std::fs;

heed/src/databases/encrypted_database.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,9 @@ impl<KC, DC, C> EncryptedDatabase<KC, DC, C> {
319319

320320
/// Returns an iterator over all of the values of a single key.
321321
///
322-
/// You can make this iterator `Send`able between threads by
323-
/// using the `read-txn-no-tls` crate feature.
322+
/// You can make this iterator `Send`able between threads by opening
323+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
324+
/// method.
324325
///
325326
/// ```
326327
/// # use std::fs;
@@ -822,8 +823,9 @@ impl<KC, DC, C> EncryptedDatabase<KC, DC, C> {
822823

823824
/// Return a lexicographically ordered iterator of all key-value pairs in this database.
824825
///
825-
/// You can make this iterator `Send`able between threads by
826-
/// using the `read-txn-no-tls` crate feature.
826+
/// You can make this iterator `Send`able between threads by opening
827+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
828+
/// method.
827829
///
828830
/// ```
829831
/// # use std::fs;
@@ -920,8 +922,9 @@ impl<KC, DC, C> EncryptedDatabase<KC, DC, C> {
920922

921923
/// Return a reversed lexicographically ordered iterator of all key-value pairs in this database.
922924
///
923-
/// You can make this iterator `Send`able between threads by
924-
/// using the `read-txn-no-tls` crate feature.
925+
/// You can make this iterator `Send`able between threads by opening
926+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
927+
/// method.
925928
///
926929
/// ```
927930
/// # use std::fs;
@@ -1021,8 +1024,9 @@ impl<KC, DC, C> EncryptedDatabase<KC, DC, C> {
10211024
///
10221025
/// Comparisons are made by using the comparator `C`.
10231026
///
1024-
/// You can make this iterator `Send`able between threads by
1025-
/// using the `read-txn-no-tls` crate feature.
1027+
/// You can make this iterator `Send`able between threads by opening
1028+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
1029+
/// method.
10261030
///
10271031
/// ```
10281032
/// # use std::fs;
@@ -1143,8 +1147,9 @@ impl<KC, DC, C> EncryptedDatabase<KC, DC, C> {
11431147
///
11441148
/// Comparisons are made by using the comparator `C`.
11451149
///
1146-
/// You can make this iterator `Send`able between threads by
1147-
/// using the `read-txn-no-tls` crate feature.
1150+
/// You can make this iterator `Send`able between threads by opening
1151+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
1152+
/// method.
11481153
///
11491154
/// ```
11501155
/// # use std::fs;
@@ -1265,8 +1270,9 @@ impl<KC, DC, C> EncryptedDatabase<KC, DC, C> {
12651270
///
12661271
/// Comparisons are made by using the bytes representation of the key.
12671272
///
1268-
/// You can make this iterator `Send`able between threads by
1269-
/// using the `read-txn-no-tls` crate feature.
1273+
/// You can make this iterator `Send`able between threads by opening
1274+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
1275+
/// method.
12701276
///
12711277
/// ```
12721278
/// # use std::fs;
@@ -1389,8 +1395,9 @@ impl<KC, DC, C> EncryptedDatabase<KC, DC, C> {
13891395
///
13901396
/// Comparisons are made by using the bytes representation of the key.
13911397
///
1392-
/// You can make this iterator `Send`able between threads by
1393-
/// using the `read-txn-no-tls` crate feature.
1398+
/// You can make this iterator `Send`able between threads by opening
1399+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
1400+
/// method.
13941401
///
13951402
/// ```
13961403
/// # use std::fs;

heed/src/envs/encrypted_env.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,10 @@ impl<T> EncryptedEnv<T> {
191191

192192
/// Create a transaction with read-only access for use with the environment.
193193
///
194-
/// You can make this transaction `Send`able between threads by
195-
/// using the `read-txn-no-tls` crate feature.
194+
/// You can make this transaction `Send`able between threads by opening
195+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
196+
/// method.
197+
///
196198
/// See [`Self::static_read_txn`] if you want the txn to own the environment.
197199
///
198200
/// ## LMDB Limitations
@@ -221,8 +223,9 @@ impl<T> EncryptedEnv<T> {
221223
/// Contrary to [`Self::read_txn`], this version **owns** the environment, which
222224
/// means you won't be able to close the environment while this transaction is alive.
223225
///
224-
/// You can make this transaction `Send`able between threads by
225-
/// using the `read-txn-no-tls` crate feature.
226+
/// You can make this transaction `Send`able between threads by opening
227+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
228+
/// method.
226229
///
227230
/// ## LMDB Limitations
228231
///

heed/src/envs/env.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,10 @@ impl<T> Env<T> {
341341

342342
/// Create a transaction with read-only access for use with the environment.
343343
///
344-
/// You can make this transaction `Send`able between threads by
345-
/// using the `read-txn-no-tls` crate feature.
344+
/// You can make this transaction `Send`able between threads by opening
345+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
346+
/// method.
347+
///
346348
/// See [`Self::static_read_txn`] if you want the txn to own the environment.
347349
///
348350
/// ## LMDB Limitations
@@ -371,8 +373,9 @@ impl<T> Env<T> {
371373
/// Contrary to [`Self::read_txn`], this version **owns** the environment, which
372374
/// means you won't be able to close the environment while this transaction is alive.
373375
///
374-
/// You can make this transaction `Send`able between threads by
375-
/// using the `read-txn-no-tls` crate feature.
376+
/// You can make this transaction `Send`able between threads by opening
377+
/// the environment with the [`EnvOpenOptions::read_txn_without_tls`]
378+
/// method.
376379
///
377380
/// ## LMDB Limitations
378381
///

heed/src/envs/env_open_options.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -457,16 +457,11 @@ impl<T: TlsUsage> EnvOpenOptions<T> {
457457
mdb_result(ffi::mdb_env_set_maxdbs(env, dbs))?;
458458
}
459459

460-
// When the `read-txn-no-tls` feature is enabled, we must force LMDB
461-
// to avoid using the thread local storage, this way we allow users
462-
// to use references of RoTxn between threads safely.
463-
#[allow(deprecated)] // NO_TLS is inside of the crate
464-
let flags = if T::ENABLED {
465-
// TODO make this a ZST flag on the Env and on RoTxn (make them Send when we can)
466-
self.flags
467-
} else {
468-
self.flags | EnvFlags::NO_TLS
469-
};
460+
// When the `<T as TlsUsage>::ENABLED` is true, we must tell
461+
// LMDB to avoid using the thread local storage, this way we
462+
// allow users to move RoTxn between threads safely.
463+
#[allow(deprecated)] // ok because NO_TLS is inside of the crate
464+
let flags = if T::ENABLED { self.flags } else { self.flags | EnvFlags::NO_TLS };
470465

471466
let result = ffi::mdb_env_open(env, path_str.as_ptr(), flags.bits(), 0o600);
472467
match mdb_result(result) {

0 commit comments

Comments
 (0)