app/assets/dev_shared_memory.html-Bq1TPb1D.js

6 lines
4.6 KiB
JavaScript
Raw Normal View History

import{_ as n,r as o,o as s,c as r,b as e,d as t,a as i,e as p}from"./app-D1iI42LG.js";const c={},l=p(`<h1 id="简介" tabindex="-1"><a class="header-anchor" href="#简介"><span>简介</span></a></h1><p>相比于普通进程通信,内存共享使得代码编写更加简洁,轻雪框架提供了一个内存共享通信的接口,你可以通过<code>shared_memory</code>模块实现内存共享通信 内存共享是线程安全的,你可以在多个线程中读写共享内存,线程锁会自动保护共享内存的读写操作</p><h2 id="快速开始" tabindex="-1"><a class="header-anchor" href="#快速开始"><span>快速开始</span></a></h2><ul><li>在任意进程中均可使用</li></ul><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">from</span> liteyuki<span class="token punctuation">.</span>comm<span class="token punctuation">.</span>storage <span class="token keyword">import</span> shared_memory
shared_memory<span class="token punctuation">.</span><span class="token builtin">set</span><span class="token punctuation">(</span><span class="token string">&quot;key&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;value&quot;</span><span class="token punctuation">)</span> <span class="token comment"># </span>
value <span class="token operator">=</span> shared_memory<span class="token punctuation">.</span>get<span class="token punctuation">(</span><span class="token string">&quot;key&quot;</span><span class="token punctuation">)</span> <span class="token comment"># </span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div>`,5),m={href:"https://github.com/LiteyukiStudio/LiteyukiBot/blob/main/liteyuki/comm/storage.py",target:"_blank",rel:"noopener noreferrer"};function d(u,h){const a=o("ExternalLinkIcon");return s(),r("div",null,[l,e("ul",null,[e("li",null,[t(""),e("a",m,[t("liteyuki/comm/storage.py"),i(a)])])])])}const k=n(c,[["render",d],["__file","dev_shared_memory.html.vue"]]),_=JSON.parse('{"path":"/dev/dev_shared_memory.html","title":"","lang":"zh-CN","frontmatter":{"title":"","icon":"exchange-alt","order":5,"category":"","description":" 使shared_memory 线线线 使 liteyuki/comm/storage.py","head":[["meta",{"property":"og:url","content":"https://vuepress-theme-hope-docs-demo.netlify.app/dev/dev_shared_memory.html"}],["meta",{"property":"og:site_name","content":"LiteyukiBot "}],["meta",{"property":"og:title","content":""}],["meta",{"property":"og:description","content":" 使shared_memory 线线线 使 liteyuki/comm/storage.py"}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:updated_time","content":"2024-08-16T16:18:06.000Z"}],["meta",{"property":"article:author","content":""}],["meta",{"property":"article:modified_time","content":"2024-08-16T16:18:06.000Z"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2024-08-16T16:18:06.000Z\\",\\"author\\":[{\\"@type\\":\\"Person\\",\\"name\\":\\"\\",\\"url\\":\\"https://sfkm.me\\"}]}"]]},"headers":[{"level":2,"title":"","slug":"","link":"#","children":[]}],"git":{"createdTime":1723825086000,"updatedTime":1723825086000,"contributors":[{"name":"snowy","email":"snowykami@outlook.com","commits":1}]},"readingTime":{"minutes":0.53,"words":159},"filePathRelative":"dev/dev_shared_memory.md","localizedDate":"2024816","autoDesc":true}');export{k as comp,_ as data};