From 65b819787668046866ffdfb181ad52ea7f516ec1 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 17 Apr 2018 13:59:55 -0700 Subject: [PATCH] better doc string for Application::with_state() --- Cargo.toml | 2 +- src/application.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f49cbf1d..adb1060b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "0.5.2" +version = "0.5.3" authors = ["Nikolay Kim "] description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust." readme = "README.md" diff --git a/src/application.rs b/src/application.rs index 411b738e..5c7b3c93 100644 --- a/src/application.rs +++ b/src/application.rs @@ -177,6 +177,13 @@ where /// /// State is shared with all resources within same application and /// could be accessed with `HttpRequest::state()` method. + /// + /// **Note**: http server accepts an application factory rather than + /// an application instance. Http server constructs an application + /// instance for each thread, thus application state must be constructed multiple + /// times. If you want to share state between different threads, a + /// shared object should be used, e.g. `Arc`. Application state does not + /// need to be `Send` and `Sync`. pub fn with_state(state: S) -> App { App { parts: Some(ApplicationParts {