Its timing is such that the fuel is injected only very slightly before top dead centre of that cylinder's compression stroke.
[1] Because of the need for positive injection into a very high-pressure environment, the pump develops great pressure—typically 15,000 psi (100 MPa) or more on newer systems.
This is a good reason to take great care when working on diesel systems; escaping fuel at this sort of pressure can easily penetrate skin and clothes, and be injected into body tissues with medical consequences serious enough to warrant amputation.
[2] Earlier diesel pumps used an in-line layout with a series of cam-operated injection cylinders in a line, rather like a miniature inline engine.
Mechanical pumps are gradually being phased out in order to comply with international emissions directives, and to increase performance and economy.