'Lock a mutex, call the function with supplied argument
when it is acquired.  If the mutex is already locked, place
function and argument in the queue.'

def lock(self, function, argument):

    if self.testandset():
        function(argument)
    else:
        self.queue.append((function, argument))
