File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -39,3 +39,7 @@ Future<void> main() async {
39
39
}
40
40
41
41
```
42
+
43
+ ## Other
44
+
45
+ - [ Using Isolate] ( isolate.dart )
Original file line number Diff line number Diff line change
1
+ import 'dart:io' ;
2
+ import 'dart:isolate' ;
3
+
4
+ import 'package:spry/spry.dart' ;
5
+
6
+ Future <void > runServer ([_]) async {
7
+ final app = createSpry ();
8
+
9
+ app.get ('/' , (_) {});
10
+ app.post ('/user' , (_) {});
11
+ app.get ('/user/:name' , (event) => event.params['name' ]);
12
+
13
+ final server = app.serve (hostname: '0.0.0.0' , port: 3000 , reusePort: true );
14
+ await server.ready ();
15
+ }
16
+
17
+ Future <void > main () async {
18
+ // Run main server.
19
+ await runServer ();
20
+
21
+ // Run cluster servers.
22
+ for (int i = Platform .numberOfProcessors - 1 ; i > 0 ; i-- ) {
23
+ await Isolate .spawn (runServer, null );
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments