mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-02-25 09:04:59 +01:00
Allow unsafe transactions to save synchronously
This commit is contained in:
@@ -39,8 +39,10 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
|
||||
/**
|
||||
Saves the transaction changes and waits for completion synchronously. This method should not be used after the `commit()` method was already called once.
|
||||
|
||||
- returns: a `SaveResult` containing the success or failure information
|
||||
*/
|
||||
public func commit() {
|
||||
public func commitAndWait() -> SaveResult {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
@@ -53,6 +55,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
|
||||
self.isCommitted = true
|
||||
self.result = self.context.saveSynchronously()
|
||||
return self.result
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,6 +200,12 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
self.context.reset()
|
||||
}
|
||||
|
||||
@available(*, deprecated=1.5.2, renamed="commitAndWait")
|
||||
public func commit() {
|
||||
|
||||
self.commitAndWait()
|
||||
}
|
||||
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
|
||||
Reference in New Issue
Block a user