Implement context manager for stack lock

This is to give the engine service methods a means to use the stack lock
that guarantees it will be released if there is an exception.

Change-Id: I6d0e1e7c22f4e74eeb069f980bc09a14f3740beb
Partial-Bug: #1321011
Merge "Implement context manager for stack lock"