MCPcopy Create free account
hub / github.com/M66B/FairEmail / lock

Method lock

app/src/main/java/androidx/sqlite/util/ProcessLock.kt:66–82  ·  view source on GitHub ↗

* Attempts to grab the lock, blocking if already held by another thread or process. * * @param [processLock] whether to use file for process level locking or not. */

Source from the content-addressed store, hash-verified

64 * @param [processLock] whether to use file for process level locking or not.
65 */
66 fun lock(processLock: Boolean = this.processLock) {
67 threadLock.lock()
68 if (processLock) {
69 try {
70 if (lockFile == null) {
71 throw IOException("No lock directory was provided.")
72 }
73 // Verify parent dir
74 val parentDir = lockFile.parentFile
75 parentDir?.mkdirs()
76 lockChannel = FileOutputStream(lockFile).channel.apply { lock() }
77 } catch (e: IOException) {
78 lockChannel = null
79 Log.w(TAG, "Unable to grab file lock.", e)
80 }
81 }
82 }
83
84 /**
85 * Releases the lock.

Callers

nothing calls this directly

Calls 3

wMethod · 0.80
lockMethod · 0.65
applyMethod · 0.45

Tested by

no test coverage detected