File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ use foundationdb:: * ;
2
+ use futures:: prelude:: * ;
3
+ use std:: sync:: Arc ;
4
+
5
+ mod common;
6
+
7
+ #[ tokio:: test]
8
+ async fn test_tokio_send ( ) {
9
+ boot_async ( || async {
10
+ do_transact ( ) . await ;
11
+ do_trx ( ) . await ;
12
+ } ) . await
13
+ }
14
+
15
+ async fn do_transact ( ) {
16
+ let db = Arc :: new (
17
+ foundationdb:: Database :: new_compat ( None )
18
+ . await
19
+ . expect ( "failed to open fdb" ) ,
20
+ ) ;
21
+
22
+ let adb = db. clone ( ) ;
23
+ tokio:: spawn ( async move {
24
+ async fn txnfn ( _txn : & Transaction ) -> FdbResult < ( ) > {
25
+ Ok ( ( ) )
26
+ }
27
+
28
+ adb. transact_boxed (
29
+ ( ) ,
30
+ |txn : & Transaction , ( ) | txnfn ( txn) . boxed ( ) ,
31
+ TransactOption :: default ( ) ,
32
+ )
33
+ . await
34
+ . expect ( "failed to transact" )
35
+ } ) ;
36
+ }
37
+
38
+ async fn do_trx ( ) {
39
+ let db = Arc :: new (
40
+ foundationdb:: Database :: new_compat ( None )
41
+ . await
42
+ . expect ( "failed to open fdb" ) ,
43
+ ) ;
44
+
45
+ let adb = db. clone ( ) ;
46
+ tokio:: spawn ( async move {
47
+ adb. create_trx ( )
48
+ . expect ( "failed to create trx" )
49
+ . commit ( )
50
+ . await
51
+ . expect ( "failed to commit" ) ;
52
+ } ) ;
53
+ }
You can’t perform that action at this time.
0 commit comments