C++ Library Extensions 2022.12.09
To help learn modern C++ programming
009-synchronization.cpp File Reference
#include <tpf_output.hpp>
#include <future>
#include <thread>
#include <condition_variable>
#include <atomic>
Include dependency graph for 009-synchronization.cpp:

Go to the source code of this file.

Functions

void worker (const char *name, int my_turn)
 
void example_for_synchronization ()
 
int main ()
 

Variables

constexpr int max_count = 12
 
constexpr int max_players = 3
 
int whose_turn = 0
 
std::atomic< int > count {0}
 
std::mutex mutex
 
std::condition_variable condition_variable
 

Function Documentation

◆ example_for_synchronization()

void example_for_synchronization ( )

Definition at line 55 of file 009-synchronization.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( )

Definition at line 81 of file 009-synchronization.cpp.

Here is the call graph for this function:

◆ worker()

void worker ( const char *  name,
int  my_turn 
)

Definition at line 18 of file 009-synchronization.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ condition_variable

std::condition_variable condition_variable

Definition at line 14 of file 009-synchronization.cpp.

◆ count

std::atomic<int> count {0}

Definition at line 11 of file 009-synchronization.cpp.

◆ max_count

constexpr int max_count = 12
constexpr

Definition at line 7 of file 009-synchronization.cpp.

◆ max_players

constexpr int max_players = 3
constexpr

Definition at line 8 of file 009-synchronization.cpp.

◆ mutex

std::mutex mutex

Definition at line 13 of file 009-synchronization.cpp.

◆ whose_turn

int whose_turn = 0

Definition at line 10 of file 009-synchronization.cpp.