aboutsummaryrefslogblamecommitdiffstats
path: root/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/GetTheLights.cpp
blob: 6e78b546ab58702be5564d32e6a4a82acbc36d5f (plain) (tree)
1
2
3
4


                                                                     






























                                                                      
/**
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */
#include <aws/core/utils/GetTheLights.h>
#include <cassert>

namespace Aws
{
    namespace Utils
    {
        GetTheLights::GetTheLights() : m_value(0)
        {
        }

        void GetTheLights::EnterRoom(std::function<void()> &&callable)
        {
            int cpy = ++m_value;
            assert(cpy > 0);
            if(cpy == 1)
            {
                callable();
            }
        }

        void GetTheLights::LeaveRoom(std::function<void()> &&callable)
        {
            int cpy = --m_value;
            assert(cpy >= 0);
            if(cpy == 0)
            {
                callable();
            }
        }
    }
}