call_once



  • Im C++14 30.4.4.2 Standard steht:
    Synchronization: For any given once_flag: all active executions occur in a total order; completion
    of an active execution synchronizes with (1.10) the start of the next one in this total order; and the
    returning execution synchronizes with the return from all passive executions.

    Kann mir bitte jemand erklären was genau gemeint ist?


  • Mod

    Das heißt so viel wie dass die passiven Aufrufe darauf warten, bis dass der aktive Aufruf fertig ist. Was wichtig ist, weil der aktive Aufruf ja oft irgendwelche einmaligen Voraussetzungen für den weiteren Ablauf schaffen wird. Sprich: call_once ist bewusst so ausgelegt, dass man damit einmalige Dinge initialisieren kann, und diese dann auch rechtzeitig bereitstehen, ohne dass man sich selbst um Synchronisation kümmern braucht.



  • @SeppJ Danke


Anmelden zum Antworten