vweb: re-enable concurrency and fix the counter example (#10484)
parent
ae014ad06d
commit
6a19a13812
|
@ -9,6 +9,11 @@ const (
|
|||
|
||||
struct App {
|
||||
vweb.Context
|
||||
mut:
|
||||
state shared State
|
||||
}
|
||||
|
||||
struct State {
|
||||
mut:
|
||||
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 {
|
||||
app.cnt++
|
||||
lock app.state {
|
||||
app.state.cnt++
|
||||
}
|
||||
show := true
|
||||
// app.text('Hello world from vweb')
|
||||
hello := 'Hello world from vweb'
|
||||
numbers := [1, 2, 3]
|
||||
app.enable_chunked_transfer(40)
|
||||
|
|
|
@ -334,7 +334,7 @@ pub fn run<T>(global_app &T, port int) {
|
|||
// conn: 0
|
||||
//}
|
||||
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