Commit 7a0d627 1 parent 488912c commit 7a0d627 Copy full SHA for 7a0d627
File tree 4 files changed +9
-4
lines changed
4 files changed +9
-4
lines changed Original file line number Diff line number Diff line change 17
17
steps :
18
18
- uses : actions/checkout@v3
19
19
- uses : actions-rust-lang/setup-rust-toolchain@v1.6
20
+ - name : install deps
21
+ run : |
22
+ sudo apt-get install -y libsqlite3-dev
20
23
- name : test examples
21
24
run : |
22
25
cd examples
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ pub mod config;
6
6
pub mod scope;
7
7
pub mod state;
8
8
pub mod vh;
9
+ pub mod mutable_state;
9
10
10
11
// <multi>
11
12
#[ ntex:: main]
Original file line number Diff line number Diff line change 1
1
// <setup_mutable>
2
2
use ntex:: web;
3
- use std:: sync:: Mutex ;
3
+ use std:: sync:: { Arc , Mutex } ;
4
4
5
+ #[ derive( Clone ) ]
5
6
struct AppStateWithCounter {
6
- counter : Mutex < i32 > , // <- Mutex is necessary to mutate safely across threads
7
+ counter : Arc < Mutex < i32 > > , // <- Mutex is necessary to mutate safely across threads
7
8
}
8
9
9
10
async fn index ( data : web:: types:: State < AppStateWithCounter > ) -> String {
@@ -19,7 +20,7 @@ async fn index(data: web::types::State<AppStateWithCounter>) -> String {
19
20
async fn main ( ) -> std:: io:: Result < ( ) > {
20
21
// Note: app state created _outside_ HttpServer::new closure
21
22
let counter = AppStateWithCounter {
22
- counter : Mutex :: new ( 0 ) ,
23
+ counter : Arc :: new ( Mutex :: new ( 0 ) ) ,
23
24
} ;
24
25
25
26
web:: HttpServer :: new ( move || {
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " ntex-website" ,
3
- "version" : " 2.0.4 " ,
3
+ "version" : " 2.0.5 " ,
4
4
"private" : true ,
5
5
"scripts" : {
6
6
"docusaurus" : " docusaurus" ,
You can’t perform that action at this time.
0 commit comments