Bug #43314 New Feature: Scoped Locking - GET_SCOPED_LOCK()
Submitted: 2 Mar 2009 23:15 Modified: 3 Mar 2009 9:11
Reporter: Van Stokes Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Locking Severity:S4 (Feature request)
Version:6.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: locking, Process, scope

[2 Mar 2009 23:15] Van Stokes
Description:
Add a new LOCK type ( very similar to GET_LOCK() ) that will lock a string but only while the lock has scope. As soon as the scope is lost the lock is automatically released. It should work exactly like the boost library "Scoped Lock".

How to repeat:
EXAMPLE IMPLEMENTATIONS
----------------------

BEGIN

   DECLARE mLock BOOLEAN DEFAULT FALSE;
   
   //This will lock the mutex
   SET mLock = GET_SCOPED_LOCK( "StringKey", 10 );
   
   //Some code

   //The scoped lock will be automatically be unlocked here
END;

BEGIN

   DECLARE mLock BOOLEAN DEFAULT FALSE;

   //Some code

   IF SomeCondiditon = TRUE THEN
   BEGIN
        //This will lock the mutex
        SET mLock = GET_SCOPED_LOCK( "StringKey", 10 );
   
        //Some code

        //The scoped lock will be automatically be unlocked here
   END;

   //Some code

   MyLoop: LOOP

        //Some code
        
       IF SomeCondiditon = TRUE THEN
       BEGIN
            //This will lock the mutex
            SET mLock = GET_SCOPED_LOCK( "StringKey", 10 );
   
            //Some code

            //The scoped lock will be automatically be unlocked here
       END;

   END LOOP: MyLoop

END;

Suggested fix:
See "Scoped Lock" at http://www.boost.org/doc/libs/1_38_0/doc/html/interprocess/synchronization_mechanisms.html...)
for implementation.
[3 Mar 2009 9:11] Valeriy Kravchuk
Thank you for a reasonable feature request.