SDL_PeepEvent losses mouse clicks

SDL_PeepEvent losses quite many mouse click events in case of very fast clicks
(as fast as I van meaning at least clicsk / sec) regardless to mouse button…
And because of this reason SDL_WaitEvent doew not fininsh (it is is fact a
wrapper for SDL_WaitEventTimeout called with timeout value -1.

I just forget to mention that there are lost mouse click events when
clicking at about the speed of 3 clicks / sec

Can you post your main loop, or an abbreviated version showing the SDL calls?

Are you calling SDL_PumpEvents on every frame before https://wiki.libsdl.org/SDL_PeepEvents ?
What are the arguments passed to SDL_PeepEvents?

I have the following setup (… means no SDL code_):

void SDL2VideoStreamPlayerWindowManager::imp::StartSDLThread(
std::promise< bool > &
sdl2InitPromise )
{
std::thread tmpThread( [ & ] { this->SDLThreadFunction( sdl2InitPromise
); } );
sdlThread.swap( tmpThread );
}

void MyClass::imp::SDLThreadFunction(…)
{
if( 0 != SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER ) )
{
sdl2InitPromise.set_value( false );

    return;
}

..............................................

if( SDL_FIRST_USER_EVENT != SDL_RegisterEvents( SDL_USER_EVENTS_COUNT )

) {
sdl2InitPromise.set_value( false );

    return;
}

...................................................

while( sdl2->WaitEvent( & event ) ) {
    switch( event.type )
    {
           case SDL_WINDOWEVENT:
           {
                 .......................

                 break;
           }

           case SDL_MOUSEBUTTONDOWN:
           case SDL_MOUSEBUTTONUP:
           {
                 // call of a notification function calling PostMessage
                 // the handling code of PostMessage send the

SDL_LAST_USER_EVENT

                 break;
           }

           case SDL_QUIT:
           {
                   SDL_Quit();

                   return;
           }

           case SDL_FIRST_USER_EVENT:
           {
                 ............................................

                  break;
           }

           case SDL_LAST_USER_EVENT:
           {
                 ............................................

                  break;
           }
    }
}

}

If there are very fast mouse clicks (something like 3 - 4 - 5 fast clicks)
the PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) call in
WIN_PumpEvents(_THIS) (video/windows/SDL_windowsevents.c)
gets into deadlock.