MicroUtils/micro_utils.dokka/dev.inmo.micro_utils.coroutines/-smart-r-w-locker/index.html
2023-09-07 22:37:15 +00:00

263 lines
28 KiB
HTML

<!DOCTYPE html>
<html class="no-js">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" charset="UTF-8">
<title>SmartRWLocker</title>
<link href="../../../images/logo-icon.svg" rel="icon" type="image/svg">
<script>var pathToRoot = "../../../";</script>
<script>document.documentElement.classList.replace("no-js","js");</script>
<script>const storage = localStorage.getItem("dokka-dark-mode")
if (storage == null) {
const osDarkSchemePreferred = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
if (osDarkSchemePreferred === true) {
document.getElementsByTagName("html")[0].classList.add("theme-dark")
}
} else {
const savedDarkMode = JSON.parse(storage)
if(savedDarkMode === true) {
document.getElementsByTagName("html")[0].classList.add("theme-dark")
}
}
</script>
<script type="text/javascript" src="https://unpkg.com/kotlin-playground@1/dist/playground.min.js" async="async"></script>
<script type="text/javascript" src="../../../scripts/sourceset_dependencies.js" async="async"></script>
<link href="../../../styles/style.css" rel="Stylesheet">
<link href="../../../styles/main.css" rel="Stylesheet">
<link href="../../../styles/prism.css" rel="Stylesheet">
<link href="../../../styles/logo-styles.css" rel="Stylesheet">
<link href="../../../styles/font-jb-sans-auto.css" rel="Stylesheet">
<script type="text/javascript" src="../../../scripts/clipboard.js" async="async"></script>
<script type="text/javascript" src="../../../scripts/navigation-loader.js" async="async"></script>
<script type="text/javascript" src="../../../scripts/platform-content-handler.js" async="async"></script>
<script type="text/javascript" src="../../../scripts/main.js" defer="defer"></script>
<script type="text/javascript" src="../../../scripts/prism.js" async="async"></script>
<script type="text/javascript" src="../../../scripts/symbol-parameters-wrapper_deferred.js" defer="defer"></script>
</head>
<body>
<div class="root">
<nav class="navigation" id="navigation-wrapper">
<div class="navigation--inner">
<div class="navigation-title">
<button class="menu-toggle" id="menu-toggle" type="button">toggle menu</button>
<div class="library-name">
<a class="library-name--link" href="../../../index.html">
micro_utils.dokka
</a>
</div>
<div class="library-version">
0.20.6 </div>
</div>
<div class="filter-section" id="filter-section">
<button class="platform-tag platform-selector common-like" data-active="" data-filter=":micro_utils.dokka:dokkaHtml/commonMain">common</button>
</div>
</div>
<div class="navigation-controls">
<button class="navigation-controls--btn navigation-controls--theme" id="theme-toggle-button" type="button">switch theme</button>
<div class="navigation-controls--btn navigation-controls--search" id="searchBar" role="button">search in API</div>
</div>
</nav>
<div id="container">
<div class="sidebar" id="leftColumn">
<div class="sidebar--inner" id="sideMenu"></div>
</div>
<div id="main">
<div class="main-content" data-page-type="classlike" id="content" pageIds="micro_utils.dokka::dev.inmo.micro_utils.coroutines/SmartRWLocker///PointingToDeclaration//-1478683138">
<div class="breadcrumbs"><a href="../../../index.html">micro_utils.dokka</a><span class="delimiter">/</span><a href="../index.html">dev.inmo.micro_utils.coroutines</a><span class="delimiter">/</span><span class="current">SmartRWLocker</span></div>
<div class="cover ">
<h1 class="cover"><span>Smart</span><wbr></wbr><span><span>RWLocker</span></span></h1>
<div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":micro_utils.dokka:dokkaHtml/commonMain"><div class="symbol monospace"><span class="token keyword">class </span><a href="index.html">SmartRWLocker</a><span class="token punctuation">(</span><span class="parameters "><span class="parameter ">readPermits<span class="token operator">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a><span class="token operator"> = </span>Int.MAX_VALUE<span class="token punctuation">, </span></span><span class="parameter ">writeIsLocked<span class="token operator">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a><span class="token operator"> = </span><span class="token boolean">false</span></span></span><span class="token punctuation">)</span><span class="clearfix"><span class="floating-right">(<a href="https://github.com/InsanusMokrassar/MicroUtils/blob/master//coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/SmartRWLocker.kt#L15">source</a>)</span></span></div><p class="paragraph">Composite mutex which works with next rules:</p><ul><li><p class="paragraph"><a href="acquire-read.html">acquireRead</a> require to <a href="write-mutex.html">writeMutex</a> be free. Then it will take one lock from <a href="read-semaphore.html">readSemaphore</a></p></li><li><p class="paragraph"><a href="release-read.html">releaseRead</a> will just free up one permit in <a href="read-semaphore.html">readSemaphore</a></p></li><li><p class="paragraph"><a href="lock-write.html">lockWrite</a> will lock <a href="write-mutex.html">writeMutex</a> and then await while all <a href="read-semaphore.html">readSemaphore</a> will be freed</p></li><li><p class="paragraph"><a href="unlock-write.html">unlockWrite</a> will just unlock <a href="write-mutex.html">writeMutex</a></p></li></ul></div></div>
</div>
<div class="tabbedcontent">
<div class="tabs-section" tabs-section="tabs-section"><button class="section-tab" data-active="" data-togglable="CONSTRUCTOR,TYPE,PROPERTY,FUNCTION">Members</button><button class="section-tab" data-togglable="CONSTRUCTOR,TYPE,PROPERTY,FUNCTION,EXTENSION_PROPERTY,EXTENSION_FUNCTION">Members &amp; Extensions</button></div>
<div class="tabs-section-body">
<div data-togglable="CONSTRUCTOR">
<h2 class="">Constructors</h2>
<div class="table"><a data-name="-288500552%2FConstructors%2F-1478683138" anchor-label="SmartRWLocker" id="-288500552%2FConstructors%2F-1478683138" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain"></a>
<div class="table-row" data-togglable="CONSTRUCTOR" data-filterable-current=":micro_utils.dokka:dokkaHtml/commonMain" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain">
<div class="main-subrow keyValue ">
<div class=""><span class="inline-flex">
<div><a href="-smart-r-w-locker.html"><span>Smart</span><wbr></wbr><span><span>RWLocker</span></span></a></div>
<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="-288500552%2FConstructors%2F-1478683138"></span>
<div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
</span></span></div>
<div>
<div class="title">
<div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":micro_utils.dokka:dokkaHtml/commonMain"><div class="symbol monospace"><span class="token keyword">constructor</span><span class="token punctuation">(</span><span class="parameters "><span class="parameter ">readPermits<span class="token operator">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a><span class="token operator"> = </span>Int.MAX_VALUE<span class="token punctuation">, </span></span><span class="parameter ">writeIsLocked<span class="token operator">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a><span class="token operator"> = </span><span class="token boolean">false</span></span></span><span class="token punctuation">)</span></div></div></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div data-togglable="PROPERTY">
<h2 class="">Properties</h2>
<div class="table"><a data-name="-1154188474%2FProperties%2F-1478683138" anchor-label="readSemaphore" id="-1154188474%2FProperties%2F-1478683138" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain"></a>
<div class="table-row" data-filterable-current=":micro_utils.dokka:dokkaHtml/commonMain" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain">
<div class="main-subrow keyValue ">
<div class=""><span class="inline-flex">
<div><a href="read-semaphore.html"><span>read</span><wbr></wbr><span><span>Semaphore</span></span></a></div>
<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="-1154188474%2FProperties%2F-1478683138"></span>
<div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
</span></span></div>
<div>
<div class="title">
<div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":micro_utils.dokka:dokkaHtml/commonMain"><div class="symbol monospace"><span class="token keyword"></span><span class="token keyword">val </span><a href="read-semaphore.html">readSemaphore</a><span class="token operator">: </span><a href="../-smart-semaphore/-immutable/index.html">SmartSemaphore.Immutable</a></div></div></div>
</div>
</div>
</div>
</div>
<a data-name="168321318%2FProperties%2F-1478683138" anchor-label="writeMutex" id="168321318%2FProperties%2F-1478683138" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain"></a>
<div class="table-row" data-filterable-current=":micro_utils.dokka:dokkaHtml/commonMain" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain">
<div class="main-subrow keyValue ">
<div class=""><span class="inline-flex">
<div><a href="write-mutex.html"><span>write</span><wbr></wbr><span><span>Mutex</span></span></a></div>
<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="168321318%2FProperties%2F-1478683138"></span>
<div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
</span></span></div>
<div>
<div class="title">
<div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":micro_utils.dokka:dokkaHtml/commonMain"><div class="symbol monospace"><span class="token keyword"></span><span class="token keyword">val </span><a href="write-mutex.html">writeMutex</a><span class="token operator">: </span><a href="../-smart-mutex/-immutable/index.html">SmartMutex.Immutable</a></div></div></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div data-togglable="FUNCTION">
<h2 class="">Functions</h2>
<div class="table"><a data-name="1410150536%2FFunctions%2F-1478683138" anchor-label="acquireRead" id="1410150536%2FFunctions%2F-1478683138" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain"></a>
<div class="table-row" data-filterable-current=":micro_utils.dokka:dokkaHtml/commonMain" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain">
<div class="main-subrow keyValue ">
<div class=""><span class="inline-flex">
<div><a href="acquire-read.html"><span>acquire</span><wbr></wbr><span><span>Read</span></span></a></div>
<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="1410150536%2FFunctions%2F-1478683138"></span>
<div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
</span></span></div>
<div>
<div class="title">
<div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":micro_utils.dokka:dokkaHtml/commonMain"><div class="symbol monospace"><span class="token keyword">suspend </span><span class="token keyword">fun </span><a href="acquire-read.html"><span class="token function">acquireRead</span></a><span class="token punctuation">(</span><span class="token punctuation">)</span></div><div class="brief "><p class="paragraph">Do lock in <a href="read-semaphore.html">readSemaphore</a> inside of <a href="write-mutex.html">writeMutex</a> locking</p></div></div></div>
</div>
</div>
</div>
</div>
<a data-name="1355423072%2FFunctions%2F-1478683138" anchor-label="lockWrite" id="1355423072%2FFunctions%2F-1478683138" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain"></a>
<div class="table-row" data-filterable-current=":micro_utils.dokka:dokkaHtml/commonMain" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain">
<div class="main-subrow keyValue ">
<div class=""><span class="inline-flex">
<div><a href="lock-write.html"><span>lock</span><wbr></wbr><span><span>Write</span></span></a></div>
<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="1355423072%2FFunctions%2F-1478683138"></span>
<div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
</span></span></div>
<div>
<div class="title">
<div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":micro_utils.dokka:dokkaHtml/commonMain"><div class="symbol monospace"><span class="token keyword">suspend </span><span class="token keyword">fun </span><a href="lock-write.html"><span class="token function">lockWrite</span></a><span class="token punctuation">(</span><span class="token punctuation">)</span></div><div class="brief "><p class="paragraph">Locking <a href="write-mutex.html">writeMutex</a> and wait while all <a href="read-semaphore.html">readSemaphore</a> permits will be freed</p></div></div></div>
</div>
</div>
</div>
</div>
<a data-name="-1640127753%2FFunctions%2F-1478683138" anchor-label="releaseRead" id="-1640127753%2FFunctions%2F-1478683138" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain"></a>
<div class="table-row" data-filterable-current=":micro_utils.dokka:dokkaHtml/commonMain" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain">
<div class="main-subrow keyValue ">
<div class=""><span class="inline-flex">
<div><a href="release-read.html"><span>release</span><wbr></wbr><span><span>Read</span></span></a></div>
<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="-1640127753%2FFunctions%2F-1478683138"></span>
<div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
</span></span></div>
<div>
<div class="title">
<div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":micro_utils.dokka:dokkaHtml/commonMain"><div class="symbol monospace"><span class="token keyword">suspend </span><span class="token keyword">fun </span><a href="release-read.html"><span class="token function">releaseRead</span></a><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a></div><div class="brief "><p class="paragraph">Release one read permit in <a href="read-semaphore.html">readSemaphore</a></p></div></div></div>
</div>
</div>
</div>
</div>
<a data-name="315522041%2FFunctions%2F-1478683138" anchor-label="unlockWrite" id="315522041%2FFunctions%2F-1478683138" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain"></a>
<div class="table-row" data-filterable-current=":micro_utils.dokka:dokkaHtml/commonMain" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain">
<div class="main-subrow keyValue ">
<div class=""><span class="inline-flex">
<div><a href="unlock-write.html"><span>unlock</span><wbr></wbr><span><span>Write</span></span></a></div>
<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="315522041%2FFunctions%2F-1478683138"></span>
<div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
</span></span></div>
<div>
<div class="title">
<div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":micro_utils.dokka:dokkaHtml/commonMain"><div class="symbol monospace"><span class="token keyword">suspend </span><span class="token keyword">fun </span><a href="unlock-write.html"><span class="token function">unlockWrite</span></a><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a></div><div class="brief "><p class="paragraph">Unlock <a href="write-mutex.html">writeMutex</a></p></div></div></div>
</div>
</div>
</div>
</div>
<a data-name="1443039409%2FFunctions%2F-1478683138" anchor-label="waitReadRelease" id="1443039409%2FFunctions%2F-1478683138" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain"></a>
<div class="table-row" data-togglable="EXTENSION_FUNCTION" data-filterable-current=":micro_utils.dokka:dokkaHtml/commonMain" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain">
<div class="main-subrow keyValue ">
<div class=""><span class="inline-flex">
<div><a href="../wait-read-release.html"><span>wait</span><wbr></wbr><span>Read</span><wbr></wbr><span><span>Release</span></span></a></div>
<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="1443039409%2FFunctions%2F-1478683138"></span>
<div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
</span></span></div>
<div>
<div class="title">
<div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":micro_utils.dokka:dokkaHtml/commonMain"><div class="symbol monospace"><span class="token keyword">suspend </span><span class="token keyword">fun </span><a href="index.html">SmartRWLocker</a><span class="token punctuation">.</span><a href="../wait-read-release.html"><span class="token function">waitReadRelease</span></a><span class="token punctuation">(</span><span class="parameters "><span class="parameter ">permits<span class="token operator">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a><span class="token operator"> = </span><span class="token constant">1</span></span></span><span class="token punctuation">)</span><span class="token operator">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html">Int</a></div><div class="brief "><p class="paragraph">Will wait until the <a href="../-smart-semaphore/permits-state-flow.html">SmartSemaphore.permitsStateFlow</a> of <span data-unresolved-link="dev.inmo.micro_utils.coroutines//&amp;lt;this&amp;gt;/#/PointingToCallableParameters(-1)/">this</span> instance will have <a href="../wait-read-release.html">permits</a> count free permits.</p></div></div></div>
</div>
</div>
</div>
</div>
<a data-name="-1144357947%2FFunctions%2F-1478683138" anchor-label="waitWriteUnlock" id="-1144357947%2FFunctions%2F-1478683138" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain"></a>
<div class="table-row" data-togglable="EXTENSION_FUNCTION" data-filterable-current=":micro_utils.dokka:dokkaHtml/commonMain" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain">
<div class="main-subrow keyValue ">
<div class=""><span class="inline-flex">
<div><a href="../wait-write-unlock.html"><span>wait</span><wbr></wbr><span>Write</span><wbr></wbr><span><span>Unlock</span></span></a></div>
<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="-1144357947%2FFunctions%2F-1478683138"></span>
<div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
</span></span></div>
<div>
<div class="title">
<div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":micro_utils.dokka:dokkaHtml/commonMain"><div class="symbol monospace"><span class="token keyword">suspend </span><span class="token keyword">fun </span><a href="index.html">SmartRWLocker</a><span class="token punctuation">.</span><a href="../wait-write-unlock.html"><span class="token function">waitWriteUnlock</span></a><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a></div><div class="brief "><p class="paragraph">Will wait until the <a href="../-smart-mutex/lock-state-flow.html">SmartMutex.lockStateFlow</a> of <span data-unresolved-link="dev.inmo.micro_utils.coroutines//&amp;lt;this&amp;gt;/#/PointingToCallableParameters(-1)/">this</span> instance will be false.</p></div></div></div>
</div>
</div>
</div>
</div>
<a data-name="-108893048%2FFunctions%2F-1478683138" anchor-label="withReadAcquire" id="-108893048%2FFunctions%2F-1478683138" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain"></a>
<div class="table-row" data-togglable="EXTENSION_FUNCTION" data-filterable-current=":micro_utils.dokka:dokkaHtml/commonMain" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain">
<div class="main-subrow keyValue ">
<div class=""><span class="inline-flex">
<div><a href="../with-read-acquire.html"><span>with</span><wbr></wbr><span>Read</span><wbr></wbr><span><span>Acquire</span></span></a></div>
<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="-108893048%2FFunctions%2F-1478683138"></span>
<div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
</span></span></div>
<div>
<div class="title">
<div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":micro_utils.dokka:dokkaHtml/commonMain"><div class="symbol monospace"><span class="token keyword">inline suspend </span><span class="token keyword">fun </span><span class="token operator">&lt;</span><span class="token keyword"></span><a href="../with-read-acquire.html">T</a><span class="token operator">&gt; </span><a href="index.html">SmartRWLocker</a><span class="token punctuation">.</span><a href="../with-read-acquire.html"><span class="token function">withReadAcquire</span></a><span class="token punctuation">(</span><span class="parameters "><span class="parameter ">action<span class="token operator">: </span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator"> -&gt; </span><span class="token keyword"></span><a href="../with-read-acquire.html">T</a></span></span><span class="token punctuation">)</span><span class="token operator">: </span><a href="../with-read-acquire.html">T</a></div><div class="brief "><p class="paragraph">Will call SmartSemaphore.Mutable.lock, then execute <a href="../with-read-acquire.html">action</a> and return the result after SmartSemaphore.Mutable.unlock</p></div></div></div>
</div>
</div>
</div>
</div>
<a data-name="-184649794%2FFunctions%2F-1478683138" anchor-label="withWriteLock" id="-184649794%2FFunctions%2F-1478683138" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain"></a>
<div class="table-row" data-togglable="EXTENSION_FUNCTION" data-filterable-current=":micro_utils.dokka:dokkaHtml/commonMain" data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain">
<div class="main-subrow keyValue ">
<div class=""><span class="inline-flex">
<div><a href="../with-write-lock.html"><span>with</span><wbr></wbr><span>Write</span><wbr></wbr><span><span>Lock</span></span></a></div>
<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="-184649794%2FFunctions%2F-1478683138"></span>
<div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
</span></span></div>
<div>
<div class="title">
<div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":micro_utils.dokka:dokkaHtml/commonMain"><div class="symbol monospace"><span class="token keyword">inline suspend </span><span class="token keyword">fun </span><span class="token operator">&lt;</span><span class="token keyword"></span><a href="../with-write-lock.html">T</a><span class="token operator">&gt; </span><a href="index.html">SmartRWLocker</a><span class="token punctuation">.</span><a href="../with-write-lock.html"><span class="token function">withWriteLock</span></a><span class="token punctuation">(</span><span class="parameters "><span class="parameter ">action<span class="token operator">: </span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator"> -&gt; </span><span class="token keyword"></span><a href="../with-write-lock.html">T</a></span></span><span class="token punctuation">)</span><span class="token operator">: </span><a href="../with-write-lock.html">T</a></div><div class="brief "><p class="paragraph">Will call <a href="../-smart-mutex/-mutable/lock.html">SmartMutex.Mutable.lock</a>, then execute <a href="../with-write-lock.html">action</a> and return the result after <a href="../-smart-mutex/-mutable/unlock.html">SmartMutex.Mutable.unlock</a></p></div></div></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<span class="go-to-top-icon"><a href="#content" id="go-to-top-link"></a></span><span>© 2023 Copyright</span><span
class="pull-right"><span>Generated by </span><a
href="https://github.com/Kotlin/dokka"><span>dokka</span><span class="padded-icon"></span></a></span>
</div>
</div>
</div>
</div>
</body>
</html>