* Acquire the content_lock for the buffer, but only if we don't have to wait. * * This assumes the caller wants BUFFER_LOCK_EXCLUSIVE mode. */
| 4313 | * This assumes the caller wants BUFFER_LOCK_EXCLUSIVE mode. |
| 4314 | */ |
| 4315 | bool |
| 4316 | ConditionalLockBuffer(Buffer buffer) |
| 4317 | { |
| 4318 | BufferDesc *buf; |
| 4319 | |
| 4320 | Assert(BufferIsPinned(buffer)); |
| 4321 | if (BufferIsLocal(buffer)) |
| 4322 | return true; /* act as though we got it */ |
| 4323 | |
| 4324 | buf = GetBufferDescriptor(buffer - 1); |
| 4325 | |
| 4326 | return ConditionalAcquireContentLock(buf, LW_EXCLUSIVE); |
| 4327 | } |
| 4328 | |
| 4329 | /* |
| 4330 | * LockBufferForCleanup - lock a buffer in preparation for deleting items |
no test coverage detected