Skip to content

Commit

Permalink
feat: more article
Browse files Browse the repository at this point in the history
  • Loading branch information
xujianhai666 committed Mar 8, 2021
1 parent 94318d1 commit 94b625b
Show file tree
Hide file tree
Showing 222 changed files with 6,888 additions and 332 deletions.
2 changes: 1 addition & 1 deletion 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ <h1>404</h1>
<footer class="footer">
<div class="footer__inner">
<div class="footer__content">
<span>&copy; 2020</span>
<span>&copy; 2021</span>

<span><a href="https://xujianhai.fun/">Zero xu</a></span>

Expand Down
2 changes: 1 addition & 1 deletion about/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ <h2 id="经历">经历</h2>
<footer class="footer">
<div class="footer__inner">
<div class="footer__content">
<span>&copy; 2020</span>
<span>&copy; 2021</span>

<span><a href="https://xujianhai.fun/">Zero xu</a></span>

Expand Down
2 changes: 1 addition & 1 deletion categories/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ <h1>Categories</h1>
<footer class="footer">
<div class="footer__inner">
<div class="footer__content">
<span>&copy; 2020</span>
<span>&copy; 2021</span>

<span><a href="https://xujianhai.fun/">Zero xu</a></span>

Expand Down
2 changes: 1 addition & 1 deletion categories/pulsar/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ <h1>pulsar</h1>
<footer class="footer">
<div class="footer__inner">
<div class="footer__content">
<span>&copy; 2020</span>
<span>&copy; 2021</span>

<span><a href="https://xujianhai.fun/">Zero xu</a></span>

Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ <h1>zero.xu blog</h1>
<footer class="footer">
<div class="footer__inner">
<div class="footer__content">
<span>&copy; 2020</span>
<span>&copy; 2021</span>

<span><a href="https://xujianhai.fun/">Zero xu</a></span>

Expand Down
171 changes: 91 additions & 80 deletions index.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion posts/bigtable/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ <h2 id="参考">参考</h2>
<footer class="footer">
<div class="footer__inner">
<div class="footer__content">
<span>&copy; 2020</span>
<span>&copy; 2021</span>

<span><a href="https://xujianhai.fun/">Zero xu</a></span>

Expand Down
2 changes: 1 addition & 1 deletion posts/bitmap/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ <h1 class="post-title">
<footer class="footer">
<div class="footer__inner">
<div class="footer__content">
<span>&copy; 2020</span>
<span>&copy; 2021</span>

<span><a href="https://xujianhai.fun/">Zero xu</a></span>

Expand Down
2 changes: 1 addition & 1 deletion posts/blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ <h1 class="post-title">
<footer class="footer">
<div class="footer__inner">
<div class="footer__content">
<span>&copy; 2020</span>
<span>&copy; 2021</span>

<span><a href="https://xujianhai.fun/">Zero xu</a></span>

Expand Down
2 changes: 1 addition & 1 deletion posts/broken_pipe/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ <h2 id="意外">意外</h2>
<footer class="footer">
<div class="footer__inner">
<div class="footer__content">
<span>&copy; 2020</span>
<span>&copy; 2021</span>

<span><a href="https://xujianhai.fun/">Zero xu</a></span>

Expand Down
2 changes: 1 addition & 1 deletion posts/bytable/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ <h3 id="问题">问题:</h3>
<footer class="footer">
<div class="footer__inner">
<div class="footer__content">
<span>&copy; 2020</span>
<span>&copy; 2021</span>

<span><a href="https://xujianhai.fun/">Zero xu</a></span>

Expand Down
8 changes: 4 additions & 4 deletions posts/cache_alg/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
一段时间内, 大量数据被读取, 使用有限次数后(假设一次) 就不用了 一段时间内, 数据被经常使用, 使用次数很高, 然后就不使用了 使用时间窗口 &#43; lfu 就可以了. 每个元素维护一个 滑动窗口计数. 通过滑动窗口处理 短时间大量使用的场景.">
<meta itemprop="datePublished" content="2020-05-17T12:33:18&#43;08:00" />
<meta itemprop="dateModified" content="2020-05-17T12:33:18&#43;08:00" />
<meta itemprop="wordCount" content="546">
<meta itemprop="wordCount" content="547">
<meta itemprop="image" content="https://xujianhai.fun/"/>


Expand Down Expand Up @@ -240,7 +240,7 @@ <h3 id="lfu">lfu</h3>
<h2 id="缓存算法">缓存算法</h2>
<p>这个是补充内容, 记录一些缓存策略:</p>
<ul>
<li>Cache Aside: 同时更新缓存和数据库</li>
<li>Cache Aside/look aside: 同时更新缓存和数据库</li>
<li>Read/Write Through: 先更新缓存, 缓存负责同步更新数据库 (应用程序只和缓存交互)</li>
<li>Write Behind Caching: 先更新缓存, 在异步的更新数据库 (应用程序只和缓存交互, 重点在异步更新)</li>
</ul>
Expand All @@ -255,7 +255,7 @@ <h2 id="缓存算法">缓存算法</h2>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-tag meta-icon"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"></path><line x1="7" y1="7" x2="7" y2="7"></line></svg><span class="tag"><a href="https://xujianhai.fun/tags/cache">cache</a></span>
</p>

<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file-text"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>546 Words</p>
<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file-text"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>547 Words</p>

<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-calendar"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>2020-05-17 12:33 &#43;0800</p>
</div>
Expand Down Expand Up @@ -298,7 +298,7 @@ <h2 id="缓存算法">缓存算法</h2>
<footer class="footer">
<div class="footer__inner">
<div class="footer__content">
<span>&copy; 2020</span>
<span>&copy; 2021</span>

<span><a href="https://xujianhai.fun/">Zero xu</a></span>

Expand Down
2 changes: 1 addition & 1 deletion posts/conn_close/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ <h2 id="参考">参考</h2>
<footer class="footer">
<div class="footer__inner">
<div class="footer__content">
<span>&copy; 2020</span>
<span>&copy; 2021</span>

<span><a href="https://xujianhai.fun/">Zero xu</a></span>

Expand Down
2 changes: 1 addition & 1 deletion posts/consistent-hash-overall/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ <h2 id="reference">reference</h2>
<footer class="footer">
<div class="footer__inner">
<div class="footer__content">
<span>&copy; 2020</span>
<span>&copy; 2021</span>

<span><a href="https://xujianhai.fun/">Zero xu</a></span>

Expand Down
68 changes: 63 additions & 5 deletions posts/cpp_basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
奇怪了, __atomic_compare_exchange_n 中 success fail 是在哪一步起作用的?为什么 fail 的 memory order 要弱于 success?">
<meta itemprop="datePublished" content="2020-04-05T19:36:11&#43;08:00" />
<meta itemprop="dateModified" content="2020-04-05T19:36:11&#43;08:00" />
<meta itemprop="wordCount" content="751">
<meta itemprop="wordCount" content="875">
<meta itemprop="image" content="https://xujianhai.fun/"/>


Expand Down Expand Up @@ -128,7 +128,7 @@
<main class="post">

<div class="post-info">
<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-clock"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>4 minutes
<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-clock"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>5 minutes



Expand Down Expand Up @@ -365,7 +365,65 @@ <h3 id="其他概念">其他概念</h3>
<p><em>仿函数</em></p>
<p>函数指针 使函数作为参数 传递给处理逻辑, 解耦了 可插拔逻辑, 但是函数指针并不能维护 一些本地信息: 比如局部变量, 这个时候可以使用 Functor/仿函数,</p>
<p><a href="https://cloud.tencent.com/developer/article/1347883">https://cloud.tencent.com/developer/article/1347883</a></p>
<h2 id="总结">总结</h2>
<h2 id="设计模式">设计模式</h2>
<p>单例</p>
<pre><code>#include &lt;stddef.h&gt;
#include &lt;memory&gt;
#include &lt;mutex&gt; // NOLINT(build/c++11)
#include &lt;utility&gt;
#include &quot;include/macros.h&quot;

namespace byte {
template &lt;typename T&gt;
class SingletonBase {
private:
// Used to check destructed of object.
struct Holder {
T value;
bool is_alive;

template &lt;typename... Args&gt;
Holder(Holder** holder, Args&amp;&amp;... args) // NOLINT(runtime/explicit)
: value(std::forward&lt;Args&gt;(args)...), is_alive(true) {
*holder = this;
}

~Holder() {
is_alive = false;
}
};

protected:
SingletonBase() {}
~SingletonBase() {}

public:
// Construct singleton parameters.
template &lt;typename... Args&gt;
static T* Instance(Args&amp;&amp;... args) {
std::call_once(s_once_flag_, [] (Args&amp;&amp;... holder_args) {
static Holder holder(&amp;s_holder_, std::forward&lt;Args&gt;(holder_args)...);
}, std::forward&lt;Args&gt;(args)...);
return &amp;s_holder_-&gt;value;
}

static bool IsAlive() {
return s_holder_.get() &amp;&amp; s_holder_-&gt;is_alive;
}

private:
static Holder* s_holder_;
static std::once_flag s_once_flag_;

DISALLOW_COPY_AND_ASSIGN(SingletonBase);
};

template &lt;typename T&gt;
typename SingletonBase&lt;T&gt;::Holder* SingletonBase&lt;T&gt;::s_holder_;

template &lt;typename T&gt;
typename std::once_flag SingletonBase&lt;T&gt;::s_once_flag_;
</code></pre><h2 id="总结">总结</h2>
<p>目前参考 <a href="https://zh.cppreference.com">https://zh.cppreference.com</a><a href="https://zh.cppreference.com">https://zh.cppreference.com</a> 就足够了. 更多的需要example 辅助学习.</p>

</div>
Expand All @@ -378,7 +436,7 @@ <h2 id="总结">总结</h2>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-tag meta-icon"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"></path><line x1="7" y1="7" x2="7" y2="7"></line></svg><span class="tag"><a href="https://xujianhai.fun/tags/cpp">cpp</a></span>
</p>

<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file-text"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>751 Words</p>
<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file-text"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>875 Words</p>

<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-calendar"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>2020-04-05 19:36 &#43;0800</p>
</div>
Expand Down Expand Up @@ -421,7 +479,7 @@ <h2 id="总结">总结</h2>
<footer class="footer">
<div class="footer__inner">
<div class="footer__content">
<span>&copy; 2020</span>
<span>&copy; 2021</span>

<span><a href="https://xujianhai.fun/">Zero xu</a></span>

Expand Down
2 changes: 1 addition & 1 deletion posts/docker_net/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ <h2 id="参考">参考</h2>
<footer class="footer">
<div class="footer__inner">
<div class="footer__content">
<span>&copy; 2020</span>
<span>&copy; 2021</span>

<span><a href="https://xujianhai.fun/">Zero xu</a></span>

Expand Down
Loading

0 comments on commit 94b625b

Please sign in to comment.