# `GSGlyph withLayerReadLock(_:)`

*Instance Method*

Performs an operation while holding shared access to the layer collection.

## Declaration

```swift
func withLayerReadLock<E, R>(_ body: () throws(E) -> R) throws(E) -> R where E : Error
```

## Parameters

- `body` — The operation to perform.

## Return Value

The value returned by the operation.

## Discussion

This does not by itself protect mutable contents of individual layers.

## See Also

### Locking

- [`GSGlyph setLockedFast:`](/Core/GlyphsCore/GSGlyph/setLockedFast:) — Changes whether editing the glyph is disabled without registering undo.
- [`GSGlyph initLock`](/Core/GlyphsCore/GSGlyph/initLock) — Prepares the glyph for synchronized access.
- [`GSGlyph hasLock`](/Core/GlyphsCore/GSGlyph/hasLock) — Whether the glyph has been prepared for synchronized access.
- [`GSGlyph lockRead`](/Core/GlyphsCore/GSGlyph/lockRead) — Acquires shared access to glyph-level cached state.
- [`GSGlyph withReadLock(_:)`](/Core/GlyphsCore/GSGlyph/withReadLock(_:)) — Performs an operation while holding shared access to glyph-level cached state.
- [`GSGlyph unlockRead`](/Core/GlyphsCore/GSGlyph/unlockRead) — Releases shared access acquired with [`GSGlyph lockRead`](/Core/GlyphsCore/GSGlyph/lockRead).
- [`GSGlyph lockWrite`](/Core/GlyphsCore/GSGlyph/lockWrite) — Acquires exclusive access to glyph-level cached state.
- [`GSGlyph withWriteLock(_:)`](/Core/GlyphsCore/GSGlyph/withWriteLock(_:)) — Performs an operation while holding exclusive access to glyph-level cached state.
- [`GSGlyph unlockWrite`](/Core/GlyphsCore/GSGlyph/unlockWrite) — Releases exclusive access acquired with [`GSGlyph lockWrite`](/Core/GlyphsCore/GSGlyph/lockWrite).
- [`GSGlyph lockReadLayers`](/Core/GlyphsCore/GSGlyph/lockReadLayers) — Acquires shared access to the layer collection.
- [`GSGlyph unlockReadLayers`](/Core/GlyphsCore/GSGlyph/unlockReadLayers) — Releases shared access acquired with [`GSGlyph lockReadLayers`](/Core/GlyphsCore/GSGlyph/lockReadLayers).
- [`GSGlyph lockWriteLayers`](/Core/GlyphsCore/GSGlyph/lockWriteLayers) — Acquires exclusive access to the layer collection.
- [`GSGlyph withLayerWriteLock(_:)`](/Core/GlyphsCore/GSGlyph/withLayerWriteLock(_:)) — Performs an operation while holding exclusive access to the layer collection.
- [`GSGlyph unlockWriteLayers`](/Core/GlyphsCore/GSGlyph/unlockWriteLayers) — Releases exclusive access acquired with [`GSGlyph lockWriteLayers`](/Core/GlyphsCore/GSGlyph/lockWriteLayers).

