vweb: re-enable concurrency and fix the counter example (#10484)

pull/10487/head
Miccah 2021-06-16 18:08:02 -05:00 committed by GitHub
parent ae014ad06d
commit 6a19a13812
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -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)

View File

@ -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)
}
}