@@ -41,7 +41,7 @@ use std::{
4141 sync:: { atomic:: AtomicU32 , Arc , Mutex as StdMutex , OnceLock } ,
4242} ;
4343use tokio:: runtime:: { self , Runtime } ;
44- #[ cfg( not( target_arch = "wasm32 " ) ) ]
44+ #[ cfg( not( feature = "web " ) ) ]
4545use tokio:: sync:: Mutex as TokioMutex ;
4646
4747pub ( crate ) type SharedCell < T > = Arc < StdMutex < T > > ;
@@ -65,9 +65,9 @@ pub struct DbContextImpl<M: SpacetimeModule> {
6565
6666 /// Receiver channel for WebSocket messages,
6767 /// which are pre-parsed in the background by [`parse_loop`].
68- #[ cfg( not( target_arch = "wasm32 " ) ) ]
68+ #[ cfg( not( feature = "web " ) ) ]
6969 recv : Arc < TokioMutex < mpsc:: UnboundedReceiver < ParsedMessage < M > > > > ,
70- #[ cfg( target_arch = "wasm32 " ) ]
70+ #[ cfg( feature = "web " ) ]
7171 recv : SharedCell < mpsc:: UnboundedReceiver < ParsedMessage < M > > > ,
7272
7373 /// Channel into which operations which apparently mutate SDK state,
@@ -78,9 +78,9 @@ pub struct DbContextImpl<M: SpacetimeModule> {
7878
7979 /// Receive end of `pending_mutations_send`,
8080 /// from which [Self::apply_pending_mutations] and friends read mutations.
81- #[ cfg( not( target_arch = "wasm32 " ) ) ]
81+ #[ cfg( not( feature = "web " ) ) ]
8282 pending_mutations_recv : Arc < TokioMutex < mpsc:: UnboundedReceiver < PendingMutation < M > > > > ,
83- #[ cfg( target_arch = "wasm32 " ) ]
83+ #[ cfg( feature = "web " ) ]
8484 pending_mutations_recv : SharedCell < mpsc:: UnboundedReceiver < PendingMutation < M > > > ,
8585
8686 /// This connection's `Identity`.
@@ -264,12 +264,12 @@ impl<M: SpacetimeModule> DbContextImpl<M> {
264264
265265 /// Apply all queued [`PendingMutation`]s.
266266 fn apply_pending_mutations ( & self ) -> crate :: Result < ( ) > {
267- #[ cfg( not( target_arch = "wasm32 " ) ) ]
267+ #[ cfg( not( feature = "web " ) ) ]
268268 while let Ok ( Some ( pending_mutation) ) = self . pending_mutations_recv . blocking_lock ( ) . try_next ( ) {
269269 self . apply_mutation ( pending_mutation) ?;
270270 }
271271
272- #[ cfg( target_arch = "wasm32 " ) ]
272+ #[ cfg( feature = "web " ) ]
273273 while let Ok ( Some ( pending_mutation) ) = self . pending_mutations_recv . lock ( ) . unwrap ( ) . try_next ( ) {
274274 self . apply_mutation ( pending_mutation) ?;
275275 }
@@ -489,10 +489,10 @@ impl<M: SpacetimeModule> DbContextImpl<M> {
489489 // model or not.
490490
491491 let res = {
492- #[ cfg( not( target_arch = "wasm32 " ) ) ]
492+ #[ cfg( not( feature = "web " ) ) ]
493493 let mut recv = self . recv . blocking_lock ( ) ;
494494
495- #[ cfg( target_arch = "wasm32 " ) ]
495+ #[ cfg( feature = "web " ) ]
496496 let mut recv = self . recv . lock ( ) . unwrap ( ) ;
497497
498498 match recv. try_next ( ) {
@@ -519,14 +519,14 @@ impl<M: SpacetimeModule> DbContextImpl<M> {
519519 // We call this out as an incorrect and unsupported thing to do.
520520 #![ allow( clippy:: await_holding_lock) ]
521521
522- #[ cfg( not( target_arch = "wasm32 " ) ) ]
522+ #[ cfg( not( feature = "web " ) ) ]
523523 let mut pending_mutations = self . pending_mutations_recv . lock ( ) . await ;
524- #[ cfg( target_arch = "wasm32 " ) ]
524+ #[ cfg( feature = "web " ) ]
525525 let mut pending_mutations = self . pending_mutations_recv . lock ( ) . unwrap ( ) ;
526526
527- #[ cfg( not( target_arch = "wasm32 " ) ) ]
527+ #[ cfg( not( feature = "web " ) ) ]
528528 let mut recv = self . recv . lock ( ) . await ;
529- #[ cfg( target_arch = "wasm32 " ) ]
529+ #[ cfg( feature = "web " ) ]
530530 let mut recv = self . recv . lock ( ) . unwrap ( ) ;
531531
532532 // Always process pending mutations before WS messages, if they're available,
@@ -585,7 +585,7 @@ impl<M: SpacetimeModule> DbContextImpl<M> {
585585 /// Spawn a thread which does [`Self::advance_one_message_blocking`] in a loop.
586586 ///
587587 /// Called by the autogenerated `DbConnection` method of the same name.
588- #[ cfg( not( target_arch = "wasm32 " ) ) ]
588+ #[ cfg( not( feature = "web " ) ) ]
589589 pub fn run_threaded ( & self ) -> std:: thread:: JoinHandle < ( ) > {
590590 let this = self . clone ( ) ;
591591 std:: thread:: spawn ( move || loop {
@@ -597,7 +597,7 @@ impl<M: SpacetimeModule> DbContextImpl<M> {
597597 } )
598598 }
599599
600- #[ cfg( target_arch = "wasm32 " ) ]
600+ #[ cfg( feature = "web " ) ]
601601 pub fn run_threaded ( & self ) {
602602 let this = self . clone ( ) ;
603603 wasm_bindgen_futures:: spawn_local ( async move {
@@ -865,21 +865,21 @@ You must explicitly advance the connection by calling any one of:
865865Which of these methods you should call depends on the specific needs of your application,
866866but you must call one of them, or else the connection will never progress.
867867" ]
868- #[ cfg( not( target_arch = "wasm32 " ) ) ]
868+ #[ cfg( not( feature = "web " ) ) ]
869869 pub fn build ( self ) -> crate :: Result < M :: DbConnection > {
870870 let imp = self . build_impl ( ) ?;
871871 Ok ( <M :: DbConnection as DbConnection >:: new ( imp) )
872872 }
873873
874- #[ cfg( target_arch = "wasm32 " ) ]
874+ #[ cfg( feature = "web " ) ]
875875 pub async fn build ( self ) -> crate :: Result < M :: DbConnection > {
876876 let imp = self . build_impl ( ) . await ?;
877877 Ok ( <M :: DbConnection as DbConnection >:: new ( imp) )
878878 }
879879
880880 /// Open a WebSocket connection, build an empty client cache, &c,
881881 /// to construct a [`DbContextImpl`].
882- #[ cfg( not( target_arch = "wasm32 " ) ) ]
882+ #[ cfg( not( feature = "web " ) ) ]
883883 fn build_impl ( self ) -> crate :: Result < DbContextImpl < M > > {
884884 let ( runtime, handle) = enter_or_create_runtime ( ) ?;
885885 let db_callbacks = DbCallbacks :: default ( ) ;
@@ -934,7 +934,7 @@ but you must call one of them, or else the connection will never progress.
934934 Ok ( ctx_imp)
935935 }
936936
937- #[ cfg( target_arch = "wasm32 " ) ]
937+ #[ cfg( feature = "web " ) ]
938938 pub async fn build_impl ( self ) -> crate :: Result < DbContextImpl < M > > {
939939 let ( runtime, handle) = enter_or_create_runtime ( ) ?;
940940 let db_callbacks = DbCallbacks :: default ( ) ;
@@ -1104,9 +1104,9 @@ Instead of registering multiple `on_disconnect` callbacks, register a single cal
11041104fn enter_or_create_runtime ( ) -> crate :: Result < ( Option < Runtime > , runtime:: Handle ) > {
11051105 match runtime:: Handle :: try_current ( ) {
11061106 Err ( e) if e. is_missing_context ( ) => {
1107- #[ cfg( not( target_arch = "wasm32 " ) ) ]
1107+ #[ cfg( not( feature = "web " ) ) ]
11081108 let mut rt = tokio:: runtime:: Builder :: new_multi_thread ( ) ;
1109- #[ cfg( target_arch = "wasm32 " ) ]
1109+ #[ cfg( feature = "web " ) ]
11101110 let mut rt = tokio:: runtime:: Builder :: new_current_thread ( ) ;
11111111
11121112 let rt = rt
@@ -1138,7 +1138,7 @@ enum ParsedMessage<M: SpacetimeModule> {
11381138 Error ( crate :: Error ) ,
11391139}
11401140
1141- #[ cfg( not( target_arch = "wasm32 " ) ) ]
1141+ #[ cfg( not( feature = "web " ) ) ]
11421142fn spawn_parse_loop < M : SpacetimeModule > (
11431143 raw_message_recv : mpsc:: UnboundedReceiver < ws:: ServerMessage < BsatnFormat > > ,
11441144 handle : & runtime:: Handle ,
@@ -1148,7 +1148,7 @@ fn spawn_parse_loop<M: SpacetimeModule>(
11481148 ( handle, parsed_message_recv)
11491149}
11501150
1151- #[ cfg( target_arch = "wasm32 " ) ]
1151+ #[ cfg( feature = "web " ) ]
11521152fn spawn_parse_loop < M : SpacetimeModule > (
11531153 raw_message_recv : mpsc:: UnboundedReceiver < ws:: ServerMessage < BsatnFormat > > ,
11541154) -> mpsc:: UnboundedReceiver < ParsedMessage < M > > {
0 commit comments