Path: news.eternal-september.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Chris M. Thomasson" Newsgroups: comp.lang.c++ Subject: Re: Futexes ain't fast Date: Fri, 30 Aug 2024 12:43:06 -0700 Organization: A noiseless patient Spider Lines: 21 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 30 Aug 2024 21:43:06 +0200 (CEST) Injection-Info: dont-email.me; posting-host="52205d2e02d95465ac4101a55f1e89ed"; logging-data="661102"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19NEmKWo0yg/bEayD3PeKgabvFVZn6g4GE=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:Y4k93+FJ8jBG/RFGIcYHtRJr/Qo= Content-Language: en-US In-Reply-To: On 8/30/2024 9:47 AM, Bonita Montero wrote: > Am 29.08.2024 um 22:12 schrieb Chris M. Thomasson: >> On 8/29/2024 7:30 AM, Bonita Montero wrote: >>> This is by far the fastest code: >>> >>> #if defined(_WIN32) >>>      HANDLE hSem = CreateSemaphoreA( nullptr, 0, 0x7FFFFFFF, nullptr ); >>>      auto acquire = [&] { WaitForSingleObject( hSem, INFINITE ); }; >>>      auto release = [&] { ReleaseSemaphore( hSem, 1, nullptr ); }; >>> #elif defined(__unix__) >>>      sem_t sem; >>>      sem_init( &sem, 0, 0 ); >>>      auto acquire = [&] { while( sem_wait( &sem ) == EINTR ); }; >> [...] >> >> Nice touch with the EINTR. I have seen a lot of code that misses this >> aspect... Yikes! > > Signals are really sick. Well, at least your code handles the condition. :^)