StorageConnection
-
Cmn
interface StorageConnection<T : Any?> : Closeable
StorageConnection provides a way to read and write a particular type Storage objects.
Summary
Public functions |
||
|---|---|---|
suspend R |
Creates a scope for reading to allow storage reads, and will try to obtain a read lock. |
Cmn
|
suspend Unit |
writeScope(block: suspend WriteScope<T>.() -> Unit)Creates a write scope that guaranteed to only have one single writer, ensuring also that any reads within this scope have the most current data. |
Cmn
|
Public properties |
||
|---|---|---|
InterProcessCoordinator |
Provides a coordinator to guarantee data consistency across multiple threads and processes. |
Cmn
|
Extension functions |
||
|---|---|---|
suspend T |
<T : Any?> StorageConnection<T>.readData() |
Cmn
|
suspend Unit |
<T : Any?> StorageConnection<T>.writeData(value: T) |
Cmn
|
Public functions
readScope
suspend fun <R : Any?> readScope(block: suspend ReadScope<T>.(locked: Boolean) -> R): R
Creates a scope for reading to allow storage reads, and will try to obtain a read lock.
| Parameters | |
|---|---|
block: suspend ReadScope<T>.(locked: Boolean) -> R |
The block of code that is performed within this scope. Block will receive |
| Throws | |
|---|---|
androidx.datastore.core.IOException |
when there is an unrecoverable exception in reading. |
writeScope
suspend fun writeScope(block: suspend WriteScope<T>.() -> Unit): Unit
Creates a write scope that guaranteed to only have one single writer, ensuring also that any reads within this scope have the most current data.
| Throws | |
|---|---|
androidx.datastore.core.IOException |
when there is an unrecoverable exception in writing. |
Public properties
coordinator
val coordinator: InterProcessCoordinator
Provides a coordinator to guarantee data consistency across multiple threads and processes.