mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vweb: re-enable concurrency and fix the counter example (#10484)
This commit is contained in:
parent
ae014ad06d
commit
6a19a13812
@ -9,6 +9,11 @@ const (
|
|||||||
|
|
||||||
struct App {
|
struct App {
|
||||||
vweb.Context
|
vweb.Context
|
||||||
|
mut:
|
||||||
|
state shared State
|
||||||
|
}
|
||||||
|
|
||||||
|
struct State {
|
||||||
mut:
|
mut:
|
||||||
cnt int
|
cnt int
|
||||||
}
|
}
|
||||||
@ -29,9 +34,10 @@ pub fn (mut app App) user_endpoint(user string) vweb.Result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut app App) index() vweb.Result {
|
pub fn (mut app App) index() vweb.Result {
|
||||||
app.cnt++
|
lock app.state {
|
||||||
|
app.state.cnt++
|
||||||
|
}
|
||||||
show := true
|
show := true
|
||||||
// app.text('Hello world from vweb')
|
|
||||||
hello := 'Hello world from vweb'
|
hello := 'Hello world from vweb'
|
||||||
numbers := [1, 2, 3]
|
numbers := [1, 2, 3]
|
||||||
app.enable_chunked_transfer(40)
|
app.enable_chunked_transfer(40)
|
||||||
|
@ -334,7 +334,7 @@ pub fn run<T>(global_app &T, port int) {
|
|||||||
// conn: 0
|
// conn: 0
|
||||||
//}
|
//}
|
||||||
mut conn := l.accept() or { panic('accept() failed') }
|
mut conn := l.accept() or { panic('accept() failed') }
|
||||||
handle_conn<T>(mut conn, mut request_app)
|
go handle_conn<T>(mut conn, mut request_app)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user