本文整理汇总了C++中tbb::atomic::load方法的典型用法代码示例。如果您正苦于以下问题:C++ atomic::load方法的具体用法?C++ atomic::load怎么用?C++ atomic::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tbb::atomic
的用法示例。
在下文中一共展示了atomic::load方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: incLoopLog
/*
* Use atomic compare-and-swap to update val to
* val + inc (*in log-space*). Update occurs in a loop in case other
* threads update in the meantime.
*/
inline void incLoopLog(tbb::atomic<double>& val, double inc) {
double oldMass = val.load();
double returnedMass = oldMass;
double newMass{salmon::math::LOG_0};
do {
oldMass = returnedMass;
newMass = salmon::math::logAdd(oldMass, inc);
returnedMass = val.compare_and_swap(newMass, oldMass);
} while (returnedMass != oldMass);
}
示例2: incLoop
/*
* Use atomic compare-and-swap to update val to
* val + inc. Update occurs in a loop in case other
* threads update in the meantime.
*/
inline void incLoop(tbb::atomic<double>& val, double inc) {
double oldMass = val.load();
double returnedMass = oldMass;
double newMass{oldMass + inc};
do {
oldMass = returnedMass;
newMass = oldMass + inc;
returnedMass = val.compare_and_swap(newMass, oldMass);
} while (returnedMass != oldMass);
}
示例3: wrap_as_future
virtual boost::unique_future<bool> send(const safe_ptr<read_frame>& frame) override
{
bool pushed = frame_buffer_.try_push(frame);
if (pushed && !first_frame_reported_)
{
first_frame_promise_.set_value();
first_frame_reported_ = true;
}
return caspar::wrap_as_future(is_running_.load());
}
示例4: wrap_as_future
virtual boost::unique_future<bool> send(const safe_ptr<core::read_frame>& frame) override
{
auto buffer = std::make_shared<audio_buffer_16>(
core::audio_32_to_16(core::get_rearranged_and_mixed(frame->multichannel_view(), channel_layout_, channel_layout_.num_channels)));
if (!input_.try_push(std::make_pair(frame, buffer)))
graph_->set_tag("dropped-frame");
if (Status() != Playing && !started_)
{
sf::SoundStream::Initialize(2, format_desc_.audio_sample_rate);
Play();
started_ = true;
}
return wrap_as_future(is_running_.load());
}