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;
};

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



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: |

Earlier, crypto enthusiasts had created a self-described “meme app” dubbed “gm” app wherein users would greet each other with “gm” or “good morning” messages. However, in September 2021, the gm app was down after a hacker reportedly gained access to the user data. Commenting about the court's concerns about the spread of false information related to the elections, Minister Fachin noted Brazil is "facing circumstances that could put Brazil's democracy at risk." During the meeting, the information technology secretary at the TSE, Julio Valente, put forward a list of requests the court believes will disinformation. 5Telegram Channel avatar size/dimensions It’s easy to create a Telegram channel via desktop app or mobile app (for Android and iOS): A new window will come up. Enter your channel name and bio. (See the character limits above.) Click “Create.”
from us


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