| Deutsch English Français Italiano |
|
<vcae5p$340q3$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Newsgroups: comp.lang.c++
Subject: Re: Ported my proxy collector...
Date: Mon, 16 Sep 2024 16:15:05 -0700
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <vcae5p$340q3$2@dont-email.me>
References: <vcadq3$340q3$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 17 Sep 2024 01:15:05 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2d41bb0e6a21724e79465d793e720c2a";
logging-data="3277635"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+pSWvOWaSDn+8PS0SYYiJzHwuEYKkleNI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:rK5dPDeEy5Fs0iY4gPY864K6Bjo=
Content-Language: en-US
In-Reply-To: <vcadq3$340q3$1@dont-email.me>
Bytes: 2740
On 9/16/2024 4:08 PM, Chris M. Thomasson wrote:
> This is a just quick port form Relacy to C++. The collector has the
> ability to allow a lock-free stack, queues, ect... to be used without
> any DWCAS on a pop operation. Also, it takes care of memory management
> issues with the nodes...
>
> Well here is my crude test code. Keep in mind that the
> g_debug_alloc/free global's are only there for debugging purposes at
> this early stage. They can be removed. This is akin to a poor mans RCU,
> in a sense... Well, can you compile and run it when you get some really
> free time to burn?
>
> Thanks everybody. :^)
> _________________________________________
>
>
> #include <cassert>
> #include <iostream>
> #include <atomic>
> #include <thread>
>
>
> #define CT_READERS 10
> #define CT_WRITERS 10
> #define CT_THREADS (CT_WRITERS + CT_READERS)
> #define CT_ITERS 10000000
> #define CT_COLLECT 10240
Fwiw, CT_COLLECT is how many times a collection is started per writer
iteration wrt the following function:
// Push and pop nodes in the lock-free stack...
void
ct_thread_writer(
ct_shared& shared
) {
for (unsigned long i = 0; i < CT_ITERS; ++i)
{
// push
{
ct_proxy::node* n0 = new ct_proxy::node();
shared.m_stack.push(n0);
}
std::this_thread::yield();
// pop
{
ct_proxy::proxy::collector& c0 = shared.m_proxy.acquire();
shared.m_proxy.collect(c0, shared.m_stack.pop());
shared.m_proxy.release(c0);
}
if (! ((i + 1) % CT_COLLECT))
{
shared.m_proxy.collect();
}
}
}