diff --git a/packages/realm_dart/lib/src/app.dart b/packages/realm_dart/lib/src/app.dart index 3e695a645..32c58f56e 100644 --- a/packages/realm_dart/lib/src/app.dart +++ b/packages/realm_dart/lib/src/app.dart @@ -140,7 +140,7 @@ class AppConfiguration { /// * Register uses and perform various user-related operations through authentication providers /// * Synchronize data between the local device and a remote Realm App with Synchronized Realms /// {@category Application} -class App implements Finalizable { +class App { final AppHandle _handle; /// The id of this application. This is the same as the appId in the [AppConfiguration] used to @@ -260,11 +260,6 @@ enum MetadataPersistenceMode { /// @nodoc extension AppInternal on App { - @pragma('vm:never-inline') - void keepAlive() { - _handle.keepAlive(); - } - AppHandle get handle => _handle; static App create(AppHandle handle) => App._(handle); diff --git a/packages/realm_dart/lib/src/collections.dart b/packages/realm_dart/lib/src/collections.dart index 71b25dfd0..8b7665487 100644 --- a/packages/realm_dart/lib/src/collections.dart +++ b/packages/realm_dart/lib/src/collections.dart @@ -46,7 +46,7 @@ class MapChanges { } /// Describes the changes in a Realm collection since the last time the notification callback was invoked. -class RealmCollectionChanges implements Finalizable { +class RealmCollectionChanges { final CollectionChangesHandle _handle; late final CollectionChanges _changes = _handle.changes; @@ -73,10 +73,5 @@ class RealmCollectionChanges implements Finalizable { } extension RealmCollectionChangesInternal on RealmCollectionChanges { - @pragma('vm:never-inline') - void keepAlive() { - _handle.keepAlive(); - } - CollectionChanges get changes => _changes; } diff --git a/packages/realm_dart/lib/src/configuration.dart b/packages/realm_dart/lib/src/configuration.dart index 44c11ce92..e8a9cd8cb 100644 --- a/packages/realm_dart/lib/src/configuration.dart +++ b/packages/realm_dart/lib/src/configuration.dart @@ -69,7 +69,7 @@ typedef AfterResetCallback = FutureOr Function(Realm beforeResetRealm, Rea /// Configuration used to create a `Realm` instance /// {@category Configuration} -abstract class Configuration implements Finalizable { +abstract class Configuration { /// The default realm filename to be used. static String get defaultRealmName => _path.basename(defaultRealmPath); static set defaultRealmName(String name) => defaultRealmPath = _path.join(_path.dirname(defaultRealmPath), _path.basename(name)); @@ -377,11 +377,6 @@ class FlexibleSyncConfiguration extends Configuration { } extension FlexibleSyncConfigurationInternal on FlexibleSyncConfiguration { - @pragma('vm:never-inline') - void keepAlive() { - user.keepAlive(); - } - SessionStopPolicy get sessionStopPolicy => _sessionStopPolicy; set sessionStopPolicy(SessionStopPolicy value) => _sessionStopPolicy = value; } diff --git a/packages/realm_dart/lib/src/credentials.dart b/packages/realm_dart/lib/src/credentials.dart index 14189c169..6733c69e7 100644 --- a/packages/realm_dart/lib/src/credentials.dart +++ b/packages/realm_dart/lib/src/credentials.dart @@ -57,7 +57,7 @@ extension AuthProviderTypeInternal on AuthProviderType { /// A class, representing the credentials used for authenticating a [User] /// {@category Application} -class Credentials implements Finalizable { +class Credentials { final CredentialsHandle _handle; /// Returns a [Credentials] object that can be used to authenticate an anonymous user. @@ -100,18 +100,13 @@ class Credentials implements Finalizable { /// @nodoc extension CredentialsInternal on Credentials { - @pragma('vm:never-inline') - void keepAlive() { - _handle.keepAlive(); - } - CredentialsHandle get handle => _handle; } /// A class, encapsulating functionality for users, logged in with [Credentials.emailPassword()]. /// It is always scoped to a particular app. /// {@category Application} -class EmailPasswordAuthProvider implements Finalizable { +class EmailPasswordAuthProvider { final App app; /// Create a new EmailPasswordAuthProvider for the [app] @@ -160,10 +155,5 @@ class EmailPasswordAuthProvider implements Finalizable { } extension EmailPasswordAuthProviderInternal on EmailPasswordAuthProvider { - @pragma('vm:never-inline') - void keepAlive() { - app.keepAlive(); - } - static EmailPasswordAuthProvider create(App app) => EmailPasswordAuthProvider(app); } diff --git a/packages/realm_dart/lib/src/list.dart b/packages/realm_dart/lib/src/list.dart index be64591cb..800f59fbd 100644 --- a/packages/realm_dart/lib/src/list.dart +++ b/packages/realm_dart/lib/src/list.dart @@ -22,7 +22,7 @@ import 'results.dart'; /// added to or deleted from the collection or from the Realm. /// /// {@category Realm} -abstract class RealmList with RealmEntity implements List, Finalizable { +abstract class RealmList with RealmEntity implements List { late final RealmObjectMetadata? _metadata; /// Gets a value indicating whether this collection is still valid to use. @@ -255,15 +255,6 @@ extension RealmListOfObject on RealmList { /// @nodoc extension RealmListInternal on RealmList { - @pragma('vm:never-inline') - void keepAlive() { - final self = this; - if (self is ManagedRealmList) { - realm.keepAlive(); - self._handle.keepAlive(); - } - } - ManagedRealmList asManaged() => this is ManagedRealmList ? this as ManagedRealmList : throw RealmStateError('$this is not managed'); ListHandle get handle { diff --git a/packages/realm_dart/lib/src/map.dart b/packages/realm_dart/lib/src/map.dart index 9e02bfb49..32701ae87 100644 --- a/packages/realm_dart/lib/src/map.dart +++ b/packages/realm_dart/lib/src/map.dart @@ -19,7 +19,7 @@ import 'realm_class.dart'; import 'results.dart'; /// RealmMap is a collection that contains key-value pairs of . -abstract class RealmMap with RealmEntity implements MapBase, Finalizable { +abstract class RealmMap with RealmEntity implements MapBase { /// Gets a value indicating whether this collection is still valid to use. /// /// Indicates whether the [Realm] instance hasn't been closed, @@ -228,15 +228,6 @@ extension RealmMapOfObject on RealmMap { /// @nodoc extension RealmMapInternal on RealmMap { - @pragma('vm:never-inline') - void keepAlive() { - final self = this; - if (self is ManagedRealmMap) { - realm.keepAlive(); - self._handle.keepAlive(); - } - } - ManagedRealmMap asManaged() => this is ManagedRealmMap ? this as ManagedRealmMap : throw RealmStateError('$this is not managed'); MapHandle get handle { diff --git a/packages/realm_dart/lib/src/realm_class.dart b/packages/realm_dart/lib/src/realm_class.dart index a337ad27e..ade1028f7 100644 --- a/packages/realm_dart/lib/src/realm_class.dart +++ b/packages/realm_dart/lib/src/realm_class.dart @@ -115,7 +115,7 @@ export 'user.dart' show User, UserState, ApiKeyClient, UserIdentity, ApiKey, Fun /// A [Realm] instance represents a `Realm` database. /// /// {@category Realm} -class Realm implements Finalizable { +class Realm { late final RealmMetadata _metadata; late final RealmHandle _handle; final bool _isInMigration; @@ -726,15 +726,6 @@ class Transaction { /// @nodoc extension RealmInternal on Realm { - @pragma('vm:never-inline') - void keepAlive() { - _handle.keepAlive(); - final c = config; - if (c is FlexibleSyncConfiguration) { - c.keepAlive(); - } - } - RealmHandle get handle { if (_handle.released) { throw RealmClosedError('Cannot access realm that has been closed'); @@ -863,7 +854,7 @@ extension RealmInternal on Realm { } /// @nodoc -abstract class NotificationsController implements Finalizable { +abstract class NotificationsController { NotificationTokenHandle? handle; NotificationTokenHandle subscribe(); diff --git a/packages/realm_dart/lib/src/realm_object.dart b/packages/realm_dart/lib/src/realm_object.dart index 2e43d28d1..fa10e0de2 100644 --- a/packages/realm_dart/lib/src/realm_object.dart +++ b/packages/realm_dart/lib/src/realm_object.dart @@ -365,7 +365,7 @@ extension RealmEntityInternal on RealmEntity { /// /// [RealmObject] should not be used directly as it is part of the generated class hierarchy. ex: `MyClass extends _MyClass with RealmObject`. /// {@category Realm} -mixin RealmObjectBase on RealmEntity implements RealmObjectBaseMarker, Finalizable { +mixin RealmObjectBase on RealmEntity implements RealmObjectBaseMarker { ObjectHandle? _handle; RealmAccessor _accessor = RealmValuesAccessor(); static final Map _factories = { @@ -646,12 +646,6 @@ extension EmbeddedObjectExtension on EmbeddedObject { /// @nodoc //RealmObject package internal members extension RealmObjectInternal on RealmObjectBase { - @pragma('vm:never-inline') - void keepAlive() { - _realm?.keepAlive(); - _handle?.keepAlive(); - } - void manage(Realm realm, ObjectHandle handle, RealmCoreAccessor accessor, bool update) { if (_handle != null) { //most certainly a bug hence we throw an Error @@ -726,7 +720,7 @@ class UserCallbackException extends RealmException { } /// Describes the changes in on a single RealmObject since the last time the notification callback was invoked. -class RealmObjectChanges implements Finalizable { +class RealmObjectChanges { // ignore: unused_field final ObjectChangesHandle _handle; @@ -749,12 +743,7 @@ class RealmObjectChanges implements Finalizable { } /// @nodoc -extension RealmObjectChangesInternal on RealmObjectChanges { - @pragma('vm:never-inline') - void keepAlive() { - _handle.keepAlive(); - } -} +extension RealmObjectChangesInternal on RealmObjectChanges {} /// @nodoc class RealmObjectNotificationsController extends NotificationsController { diff --git a/packages/realm_dart/lib/src/results.dart b/packages/realm_dart/lib/src/results.dart index f4c669f8f..57a2ee7dc 100644 --- a/packages/realm_dart/lib/src/results.dart +++ b/packages/realm_dart/lib/src/results.dart @@ -19,7 +19,7 @@ import 'realm_object.dart'; /// added to or deleted from the Realm that match the underlying query. /// /// {@category Realm} -class RealmResults extends Iterable with RealmEntity implements Finalizable { +class RealmResults extends Iterable with RealmEntity { final RealmObjectMetadata? _metadata; final ResultsHandle _handle; final int _skipOffset; // to support skip efficiently @@ -278,11 +278,6 @@ extension RealmResultsOfRealmObject on RealmResults { /// @nodoc //RealmResults package internal members extension RealmResultsInternal on RealmResults { - @pragma('vm:never-inline') - void keepAlive() { - _handle.keepAlive(); - } - ResultsHandle get handle { if (_handle.released) { throw RealmClosedError('Cannot access Results that belongs to a closed Realm'); diff --git a/packages/realm_dart/lib/src/session.dart b/packages/realm_dart/lib/src/session.dart index 4b547e40d..e861b6f3e 100644 --- a/packages/realm_dart/lib/src/session.dart +++ b/packages/realm_dart/lib/src/session.dart @@ -14,7 +14,7 @@ import 'user.dart'; /// server. Sessions are always created by the SDK and vended out through various /// APIs. The lifespans of sessions associated with Realms are managed automatically. /// {@category Sync} -class Session implements Finalizable { +class Session { final SessionHandle _handle; /// The on-disk path of the file backing the [Realm] this [Session] represents @@ -98,11 +98,6 @@ class ConnectionStateChange { } extension SessionInternal on Session { - @pragma('vm:never-inline') - void keepAlive() { - _handle.keepAlive(); - } - static Session create(SessionHandle handle) => Session._(handle); SessionHandle get handle { diff --git a/packages/realm_dart/lib/src/set.dart b/packages/realm_dart/lib/src/set.dart index 6ac396f32..b1b1e2d22 100644 --- a/packages/realm_dart/lib/src/set.dart +++ b/packages/realm_dart/lib/src/set.dart @@ -19,7 +19,7 @@ import 'collections.dart'; import 'results.dart'; /// RealmSet is a collection that contains no duplicate elements. -abstract class RealmSet extends SetBase with RealmEntity implements Finalizable { +abstract class RealmSet extends SetBase with RealmEntity { RealmObjectMetadata? _metadata; /// Gets a value indicating whether this collection is still valid to use. diff --git a/packages/realm_dart/lib/src/subscription.dart b/packages/realm_dart/lib/src/subscription.dart index 9b4a58eba..7a5ee843c 100644 --- a/packages/realm_dart/lib/src/subscription.dart +++ b/packages/realm_dart/lib/src/subscription.dart @@ -15,7 +15,7 @@ import 'results.dart'; /// evaluate the query that the app subscribed to and will send data /// that matches it as well as remove data that no longer does. /// {@category Sync} -final class Subscription implements Finalizable { +final class Subscription { final SubscriptionHandle _handle; Subscription._(this._handle); @@ -115,7 +115,7 @@ enum SubscriptionSetState { /// Realm is an expensive operation server-side, even if there's very little data that needs /// downloading. /// {@category Sync} -sealed class SubscriptionSet with Iterable implements Finalizable { +sealed class SubscriptionSet with Iterable { final Realm _realm; SubscriptionSetHandle __handle; SubscriptionSetHandle get _handle => __handle.nullPtrAsNull ?? (throw RealmClosedError('Cannot access a SubscriptionSet that belongs to a closed Realm')); @@ -195,12 +195,6 @@ sealed class SubscriptionSet with Iterable implements Finalizable } extension SubscriptionSetInternal on SubscriptionSet { - @pragma('vm:never-inline') - void keepAlive() { - _realm.keepAlive(); - _handle.keepAlive(); - } - SubscriptionSetHandle get handle => _handle; static SubscriptionSet create(Realm realm, SubscriptionSetHandle handle) => ImmutableSubscriptionSet._(realm, handle); diff --git a/packages/realm_dart/lib/src/user.dart b/packages/realm_dart/lib/src/user.dart index 2c8e0d6a4..c02184a3a 100644 --- a/packages/realm_dart/lib/src/user.dart +++ b/packages/realm_dart/lib/src/user.dart @@ -162,7 +162,7 @@ class User { } /// @nodoc -class UserNotificationsController implements Finalizable { +class UserNotificationsController { UserNotificationTokenHandle? tokenHandle; void start() { @@ -367,12 +367,6 @@ extension UserIdentityInternal on UserIdentity { /// @nodoc extension UserInternal on User { - @pragma('vm:never-inline') - void keepAlive() { - _handle.keepAlive(); - _app?.keepAlive(); - } - UserHandle get handle => _handle; static User create(UserHandle handle, [App? app]) => User._(handle, app);