Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realm技術メモ(kotlin) #2

Open
LeoAndo opened this issue Sep 1, 2023 · 2 comments
Open

Realm技術メモ(kotlin) #2

LeoAndo opened this issue Sep 1, 2023 · 2 comments

Comments

@LeoAndo
Copy link
Owner

LeoAndo commented Sep 1, 2023

Realmの内部処理は単一のスレッドで実行される。アプリ側でスレッドを変更することはできないと思う。

以下は、Realmの内部実装

スクリーンショット 2023-09-02 11 36 08 スクリーンショット 2023-09-02 11 39 49

refs

https://github.com/search?q=repo%3Arealm%2Frealm-kotlin%20SuspendableWriter&type=code
https://github.com/realm/realm-kotlin/blob/9138b66846fac53d60c225d1962bd951206d31bd/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/SuspendableWriter.kt#L48

@LeoAndo
Copy link
Owner Author

LeoAndo commented Sep 1, 2023

RealmObjectもしくはEmbeddedRealmObjectを継承するsub classは data classではなく、classで定義すること link link2
data classにすると以下のようなコンパイルエラーが発生する

Details: Internal error in file lowering: java.lang.IllegalStateException: Data class 'jp.ac.jec.cm0199.androidrealmsample.Item' is not currently supported. Only normal classes can inherit from 'RealmObject' or 'EmbeddedRealmObject'.

@LeoAndo LeoAndo changed the title Realm技術メモ Realm技術メモ(kotlin) Sep 1, 2023
@LeoAndo
Copy link
Owner Author

LeoAndo commented Sep 2, 2023

RealmConfiguration.createメソッドはメインスレッドで呼び出さないこと。内部で重たい処理を行うため。

code

RealmConfiguration.create(schema = setOf(XXX::class))

以下の警告ログが出力される ( Logcat )

2023-09-02 12:02:20.161 11182-11182 Choreographer           jp.ac.jec.cm0199.androidrealmsample  I  Skipped 71 frames!  The application may be doing too much work on its main thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant