HFT_DEV Telegram 61
В пятницу возник интересный вопрос:
template <typename T>
class Queue {
public:
void push(const T& val) {
std::unique_lock l{_m};
_queue.push(val);
if (_queue.size() == 1) { // was empty
_not_empty_cv.notify_one();
}
}

T pop() {
std::unique_lock l{_m};
_not_empty_cv.wait(l, [&]() {
return !_queue.empty();
});
auto v = std::move(_queue.front());
_queue.pop();
return v;
}

private:
std::mutex _m;
std::condition_variable _not_empty_cv;
std::queue<T> _queue;
};

Есть ли здесь проблема?
🤔3🔥2



tgoop.com/hft_dev/61
Create:
Last Update:

В пятницу возник интересный вопрос:

template <typename T>
class Queue {
public:
void push(const T& val) {
std::unique_lock l{_m};
_queue.push(val);
if (_queue.size() == 1) { // was empty
_not_empty_cv.notify_one();
}
}

T pop() {
std::unique_lock l{_m};
_not_empty_cv.wait(l, [&]() {
return !_queue.empty();
});
auto v = std::move(_queue.front());
_queue.pop();
return v;
}

private:
std::mutex _m;
std::condition_variable _not_empty_cv;
std::queue<T> _queue;
};

Есть ли здесь проблема?

BY Один микросек - C++, low latency, concurrency, HFT


Share with your friend now:
tgoop.com/hft_dev/61

View MORE
Open in Telegram


Telegram News

Date: |

The SUCK Channel on Telegram, with a message saying some content has been removed by the police. Photo: Telegram screenshot. ZDNET RECOMMENDS In handing down the sentence yesterday, deputy judge Peter Hui Shiu-keung of the district court said that even if Ng did not post the messages, he cannot shirk responsibility as the owner and administrator of such a big group for allowing these messages that incite illegal behaviors to exist. Administrators There have been several contributions to the group with members posting voice notes of screaming, yelling, groaning, and wailing in different rhythms and pitches. Calling out the “degenerate” community or the crypto obsessives that engage in high-risk trading, Co-founder of NFT renting protocol Rentable World emiliano.eth shared this group on his Twitter. He wrote: “hey degen, are you stressed? Just let it out all out. Voice only tg channel for screaming”.
from us


Telegram Один микросек - C++, low latency, concurrency, HFT
FROM American