c++ wati for用法

c++ wati for用法

#include 
#include 
#include 

class Logger2 {
    std::queue shopping_transactionIds;
    std::mutex mtx;
    std::condition_variable cv;

public:
    std::string getShoppingTransactionId() {
        std::unique_lock lock(mtx);
        if(!cv.wait_for(lock, std::chrono::seconds(1), [this]{ return !this->shopping_transactionIds.empty(); })) {
            LOGW("shopping transaction id is empty");
            return "";
        }

        std::string transactionId = std::move(this->shopping_transactionIds.front());
        this->shopping_transactionIds.pop();
        return transactionId;
    }

    // Other class members...
};

你可能感兴趣的:(c++基础,c++,算法,开发语言)