Skip to content

Commit 52db8a4

Browse files
committed
Fix doc artifacts of removed methods
Resolves #207
1 parent af3908b commit 52db8a4

File tree

3 files changed

+40
-17
lines changed

3 files changed

+40
-17
lines changed

foundationdb/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ futures = "0.3"
4040

4141
## Initialization
4242

43-
Due to limitations in the C API, the Client and it's associated Network can only be initialized and run once per the life of a process. Generally the `foundationdb::run` function will be enough to initialize the Client. See `foundationdb::default_api` and `foundationdb::builder` for more configuration options of the Fdb Client.
43+
Due to limitations in the C API, the Client and it's associated Network can only be initialized and run once per the life of a process. Generally the `foundationdb::boot` function will be enough to initialize the Client. See `foundationdb::api` for more configuration options of the Fdb Client.
4444

4545
## Example
4646

foundationdb/src/api.rs

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,20 @@ impl NetworkBuilder {
105105
Ok(self)
106106
}
107107

108-
/// Finalizes the initialization of the Network
108+
/// Finalizes the initialization of the Network and returns a way to run/wait/stop the
109+
/// FoundationDB run loop.
109110
///
110-
/// It's not recommended to use this method unless you really know what you are doing.
111-
/// Otherwise, the `run` method is the **safe** and easiest way to do it.
111+
/// It's not recommended to use this method directly, you probably want the `boot()` method.
112112
///
113-
/// In order to start the network you have to call the unsafe `NetworkRunner::run()` method.
114-
/// This method starts the foundationdb network runloop, once started, the `NetworkStop::stop()`
115-
/// method **MUST** be called before the process exit. Aborting the process is still safe.
113+
/// In order to start the network you have to:
114+
/// - call the unsafe `NetworkRunner::run()` method, most likely in a dedicated thread
115+
/// - wait for the thread to start `NetworkWait::wait`
116+
///
117+
/// In order for the sequence to be safe, you **MUST** as stated in the `NetworkRunner::run()` method
118+
/// ensure that `NetworkStop::stop()` is called before the process exit.
119+
/// Aborting the process is still safe.
120+
///
121+
/// # Example
116122
///
117123
/// ```
118124
/// use foundationdb::api::FdbApiBuilder;
@@ -142,19 +148,25 @@ impl NetworkBuilder {
142148
Ok((NetworkRunner { cond: cond.clone() }, NetworkWait { cond }))
143149
}
144150

145-
/// Initialize the FoundationDB Client API, this can only be called once per process.
151+
/// Starts the FoundationDB run loop in a dedicated thread.
152+
/// This finish initializing the FoundationDB Client API and can only be called once per process.
146153
///
147154
/// # Returns
148155
///
149156
/// A `NetworkAutoStop` handle which must be dropped before the program exits.
150157
///
151158
/// # Safety
152159
///
160+
/// You *MUST* ensure `drop` is called on the returned object before the program exits.
161+
/// This is not required if the program is aborted.
162+
///
153163
/// This method used to be safe in version `0.4`. But because `drop` on the returned object
154164
/// might not be called before the program exits, it was found unsafe.
155-
/// You should prefer the safe `run` variant.
156-
/// If you still want to use this, you *MUST* ensure drop is called on the returned object
157-
/// before the program exits. This is not required if the program is aborted.
165+
///
166+
/// # Panics
167+
///
168+
/// Panics if the dedicated thread cannot be spawned or the internal condition primitive is
169+
/// poisonned.
158170
///
159171
/// # Examples
160172
///
@@ -194,7 +206,7 @@ impl NetworkBuilder {
194206

195207
/// A foundationDB network event loop runner
196208
///
197-
/// Most of the time you should never need to use this directly and use `NetworkBuilder::run()`.
209+
/// Most of the time you should never need to use this directly and use `boot()`.
198210
pub struct NetworkRunner {
199211
cond: Arc<(Mutex<bool>, Condvar)>,
200212
}
@@ -234,13 +246,17 @@ impl NetworkRunner {
234246

235247
/// A condition object that can wait for the associated `NetworkRunner` to actually run.
236248
///
237-
/// Most of the time you should never need to use this directly and use `NetworkBuilder::run()`.
249+
/// Most of the time you should never need to use this directly and use `boot()`.
238250
pub struct NetworkWait {
239251
cond: Arc<(Mutex<bool>, Condvar)>,
240252
}
241253

242254
impl NetworkWait {
243255
/// Wait for the associated `NetworkRunner` to actually run.
256+
///
257+
/// # Panics
258+
///
259+
/// Panics if the internal lock cannot is poisoned
244260
pub fn wait(self) -> NetworkStop {
245261
// Wait for the thread to start up.
246262
{
@@ -257,7 +273,7 @@ impl NetworkWait {
257273

258274
/// Allow to stop the associated and running `NetworkRunner`.
259275
///
260-
/// Most of the time you should never need to use this directly and use `NetworkBuilder::run()`.
276+
/// Most of the time you should never need to use this directly and use `boot()`.
261277
pub struct NetworkStop {
262278
_private: (),
263279
}
@@ -270,6 +286,13 @@ impl NetworkStop {
270286
}
271287

272288
/// Stop the associated `NetworkRunner` and thread if dropped
289+
///
290+
/// If trying to stop the FoundationDB run loop results in an error.
291+
/// The error is printed in `stderr` and the process aborts.
292+
///
293+
/// # Panics
294+
///
295+
/// Panics if the network thread cannot be joined.
273296
pub struct NetworkAutoStop {
274297
network: Option<NetworkStop>,
275298
handle: Option<std::thread::JoinHandle<()>>,

foundationdb/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ pub use crate::transaction::*;
126126
///
127127
/// # Safety
128128
///
129+
/// You *MUST* ensure drop is called on the returned object before the program exits.
130+
/// This is not required if the program is aborted.
131+
///
129132
/// This method used to be safe in version `0.4`. But because `drop` on the returned object
130133
/// might not be called before the program exits, it was found unsafe.
131-
/// You should prefer the safe `run` variant.
132-
/// If you still want to use this, you *MUST* ensure drop is called on the returned object
133-
/// before the program exits. This is not required if the program is aborted.
134134
///
135135
/// # Examples
136136
///

0 commit comments

Comments
 (0)