For the purpose of clarity, I only use "signaller" below, but the same applies to crossing keepers.
As per the earlier reply, for a manually controlled full barrier (MCB) crossing (either local to the signal box, crossing keepers box or monitored by CCTV and controlled remotely), it's the duty of the signaller to close the crossing to road traffic in sufficient time such that a train does not receive restrictive aspects. In other words, the train driver will only see green signal aspects, and hence can drive at the line speed or the maximum speed of the train (whichever is the lower figure).
If the railway line side signals are each spaced one mile from each other, in a three aspect signalled area, that means the signaller will start the close crossing procedure when the approaching train is around three to four miles away. This assumes the line speed is 60MPH, hence the train is taking 60 seconds to travel one mile. For higher speeds, the close crossing procedure needs to start even earlier.
Code:
S1 Green S2 Green S3 Yellow S4 Red
|-OOO |-OOO |-OOO |-OOO
------------------------------------------|-|---
------------------------------------------|-|---
Crossing
Above is the signal aspect sequence assuming no trains in the area and the crossing is open to road traffic. In order to ensure that the train driver does not see a restrictive aspect (that is any other than green), the signaller has to have the barriers fully lowered before the train passes signal S2. Hence the signaller will want to start the close crossing procedure as soon as they see a train approaching signal S1 or if the speed is higher, the previous signal.
I hope that helps to explain why it takes four to six minutes between a road user seeing the amber and red road lights, the barriers lowering and then a 'long wait" before the train appears.
Please note that the above is but one possible example, and for each crossing, in the real world, there are many other factors. Such as stations and junctions that mean a particular crossing has more complexities.