As Oldlock says, this is a cell lock, for an inward-opening cell door. There were made left-handed, right-handed, and for inward-opening and outward-opening doors. Inward-opening being more common. Limits of age unknown, but most date from late 19C.
It has a trigger-action - see the small square stud near the forend. When the key unlocks and withdraws the bolt against a strong spring, the bolt is held in and the key can be removed, leaving the door unsecured whilst prisoners are allowed out of their cells. Slamming the door shut causes the trigger stud to hit the doorframe and be pushed in. The strong bolt spring then projects the bolt which is instantly deadlocked - no key is needed. This is the origin of the prison expression ‘banged up’. The indicator shows the lock’s status.