File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -382,6 +382,22 @@ public enum MetricsSystem {
382382 fileprivate static var _factory : MetricsFactory = NOOPMetricsHandler . instance
383383 fileprivate static var initialized = false
384384
385+ /// Acquire a writer lock for the duration of the given block.
386+ ///
387+ /// - Parameter body: The block to execute while holding the lock.
388+ /// - Returns: The value returned by the block.
389+ public static func withWriterLock< T> ( _ body: ( ) throws -> T ) rethrows -> T {
390+ return try self . lock. withWriterLock ( body)
391+ }
392+
393+ /// Acquire a reader lock for the duration of the given block.
394+ ///
395+ /// - Parameter body: The block to execute while holding the lock.
396+ /// - Returns: The value returned by the block.
397+ public static func withReaderLock< T> ( _ body: ( ) throws -> T ) rethrows -> T {
398+ return try self . lock. withReaderLock ( body)
399+ }
400+
385401 /// `bootstrap` is an one-time configuration function which globally selects the desired metrics backend
386402 /// implementation. `bootstrap` can be called at maximum once in any given program, calling it more than once will
387403 /// lead to undefined behaviour, most likely a crash.
You can’t perform that action at this time.
0 commit comments