@@ -42,11 +42,15 @@ const MAX_INSERT_DOCS_BYTES: usize = 16 * 1000 * 1000;
4242/// [`Database::collection_with_options`](struct.Database.html#method.collection_with_options).
4343///
4444/// `Collection` uses [`std::sync::Arc`](https://doc.rust-lang.org/std/sync/struct.Arc.html) internally,
45- /// so it can safely be shared across threads. For example:
45+ /// so it can safely be shared across threads or async tasks . For example:
4646///
4747/// ```rust
4848/// # use bson::{bson, doc};
4949/// # use mongodb::error::Result;
50+ /// # #[cfg(feature = "async-std-runtime")]
51+ /// # use async_std::task;
52+ /// # #[cfg(feature = "tokio-runtime")]
53+ /// # use tokio::task;
5054/// #
5155/// # #[cfg(not(feature = "sync"))]
5256/// # async fn start_workers() -> Result<()> {
@@ -58,15 +62,12 @@ const MAX_INSERT_DOCS_BYTES: usize = 16 * 1000 * 1000;
5862/// for i in 0..5 {
5963/// let coll_ref = coll.clone();
6064///
61- /// std::thread:: spawn(move || {
65+ /// task:: spawn(async move {
6266/// // Perform operations with `coll_ref`. For example:
63- /// coll_ref.insert_one(doc! { "x": i }, None);
67+ /// coll_ref.insert_one(doc! { "x": i }, None).await ;
6468/// });
6569/// }
6670/// #
67- /// # // Technically we should join the threads here, but for the purpose of the example, we'll just
68- /// # // sleep for a bit.
69- /// # std::thread::sleep(std::time::Duration::from_secs(3));
7071/// # Ok(())
7172/// # }
7273/// ```
0 commit comments