File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,27 @@ class DatabasePoolReleaseMemoryTests: GRDBTestCase {
93
93
XCTAssertNotEqual ( 0 , dbPool. numberOfReaders)
94
94
}
95
95
}
96
+
97
+ // Regression test for <https://github.com/groue/GRDB.swift/pull/1253#issuecomment-1177166630>
98
+ func testDatabasePoolDoesNotPreventConcurrentReadsOnPressureEvent( ) throws {
99
+ let dbPool = try makeDatabasePool ( )
100
+
101
+ // Start a read that blocks
102
+ let semaphore = DispatchSemaphore ( value: 0 )
103
+ dbPool. asyncRead { _ in
104
+ semaphore. wait ( )
105
+ }
106
+
107
+ // Simulate memory warning.
108
+ NotificationCenter . default. post ( name: UIApplication . didReceiveMemoryWarningNotification, object: nil )
109
+
110
+ // Make sure we can read
111
+ try dbPool. read { _ in }
112
+
113
+ // Cleanup
114
+ semaphore. signal ( )
115
+ }
116
+
96
117
#endif
97
118
98
119
// TODO: fix flaky test
You can’t perform that action at this time.
0 commit comments