Make SCOPED_LOCK use RAII_VAR.

This fixes an issue with requiring SCOPED_LOCK to be the last variable
declaration and removes duplicate code in the process.

Review: https://reviewboard.asterisk.org/r/2665/


git-svn-id: http://svn.asterisk.org/svn/asterisk/trunk@393919 f38db490-d61c-443f-a65b-d21fe96a405b