The answer is valves.
Heart valves have a particularly important role in keeping blood flow in a certain direction, allowing blood to flow from the atria to the ventricles and from the ventricles to the heart. Valves control the flow of blood through the heart by opening and closing each time the heart contracts. The valve's opening and closing functions are controlled by the pressure difference between the heart chambers and some muscles in the heart.
In case of dysfunction of one of these valves can be made an artificial heart valve or a mechanical type