当前位置: 首页>>代码示例>>C++>>正文


C++ atomic::store方法代码示例

本文整理汇总了C++中boost::atomic::store方法的典型用法代码示例。如果您正苦于以下问题:C++ atomic::store方法的具体用法?C++ atomic::store怎么用?C++ atomic::store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::atomic的用法示例。


在下文中一共展示了atomic::store方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: plain_deferred_arguments

void plain_deferred_arguments()
{
    void_f4_count.store(0);
    int_f4_count.store(0);

    {
        future<void> f1 = dataflow(hpx::launch::deferred, &void_f4, 42);
        future<int> f2 = dataflow(hpx::launch::deferred, &int_f4, 42);

        f1.wait();
        HPX_TEST_EQ(void_f4_count, 1u);

        HPX_TEST_EQ(f2.get(), 84);
        HPX_TEST_EQ(int_f4_count, 1u);
    }

    void_f5_count.store(0);
    int_f5_count.store(0);

    {
        future<void> f1 = dataflow(&void_f5, 42, async(hpx::launch::deferred, &int_f));
        future<int> f2 = dataflow(&int_f5, 42, async(hpx::launch::deferred, &int_f));

        f1.wait();
        HPX_TEST_EQ(void_f5_count, 1u);

        HPX_TEST_EQ(f2.get(), 126);
        HPX_TEST_EQ(int_f5_count, 1u);
    }
}
开发者ID:Bcorde5,项目名称:hpx,代码行数:30,代码来源:local_dataflow.cpp

示例2: test_timed_executor

void test_timed_executor(std::array<std::size_t, 4> expected)
{
    typedef typename hpx::traits::executor_execution_category<
            Executor
        >::type execution_category;

    HPX_TEST((std::is_same<
            hpx::parallel::execution::sequenced_execution_tag,
            execution_category
        >::value));

    count_sync.store(0);
    count_apply.store(0);
    count_sync_at.store(0);
    count_apply_at.store(0);

    Executor exec;

    test_timed_apply(exec);
    test_timed_sync(exec);
    test_timed_async(exec);

    HPX_TEST_EQ(expected[0], count_sync.load());
    HPX_TEST_EQ(expected[1], count_apply.load());
    HPX_TEST_EQ(expected[2], count_sync_at.load());
    HPX_TEST_EQ(expected[3], count_apply_at.load());
}
开发者ID:atrantan,项目名称:hpx,代码行数:27,代码来源:minimal_timed_sync_executor.cpp

示例3: plain_arguments

void plain_arguments(Executor& exec)
{
    void_f4_count.store(0);
    int_f4_count.store(0);

    {
        future<void> f1 = dataflow(exec, &void_f4, 42);
        future<int> f2 = dataflow(exec, &int_f4, 42);

        f1.wait();
        HPX_TEST_EQ(void_f4_count, 1u);

        HPX_TEST_EQ(f2.get(), 84);
        HPX_TEST_EQ(int_f4_count, 1u);
    }

    void_f5_count.store(0);
    int_f5_count.store(0);

    {
        future<void> f1 = dataflow(exec, &void_f5, 42, async(&int_f));
        future<int> f2 = dataflow(exec, &int_f5, 42, async(&int_f));

        f1.wait();
        HPX_TEST_EQ(void_f5_count, 1u);

        HPX_TEST_EQ(f2.get(), 126);
        HPX_TEST_EQ(int_f5_count, 1u);
    }
}
开发者ID:Bcorde5,项目名称:hpx,代码行数:30,代码来源:local_dataflow_executor.cpp

示例4:

void	LoggingStreamImpl::UpdateIsLogging() const
{
    m_lastLoggingFilterChangeCount.store( g_LoggingFilterChangeCount.load() );

    boost::log::record		testRecord = m_logger.open_record( boost::log::keywords::severity = m_severityLevel );

    m_isLogging.store( (bool)testRecord );
}
开发者ID:stephanfr,项目名称:Utilities,代码行数:8,代码来源:Logging.cpp

示例5: future_function_pointers

void future_function_pointers()
{
    future_void_f1_count.store(0);
    future_void_f2_count.store(0);

    future<void> f1
        = dataflow(
            &future_void_f1, async(&future_void_sf1,
                shared_future<void>(make_ready_future()))
        );

    f1.wait();

    HPX_TEST_EQ(future_void_f1_count, 2u);
    future_void_f1_count.store(0);

    future<void> f2 = dataflow(
        &future_void_f2
      , async(&future_void_sf1, shared_future<void>(make_ready_future()))
      , async(&future_void_sf1, shared_future<void>(make_ready_future()))
    );

    f2.wait();
    HPX_TEST_EQ(future_void_f1_count, 2u);
    HPX_TEST_EQ(future_void_f2_count, 1u);
    future_void_f1_count.store(0);
    future_void_f2_count.store(0);

    future<int> f3 = dataflow(
        &future_int_f1
      , make_ready_future()
    );

    HPX_TEST_EQ(f3.get(), 1);
    HPX_TEST_EQ(future_int_f1_count, 1u);
    future_int_f1_count.store(0);

    future<int> f4 = dataflow(
        &future_int_f2
      , dataflow(&future_int_f1, make_ready_future())
      , dataflow(&future_int_f1, make_ready_future())
    );

    HPX_TEST_EQ(f4.get(), 2);
    HPX_TEST_EQ(future_int_f1_count, 2u);
    HPX_TEST_EQ(future_int_f2_count, 1u);
    future_int_f1_count.store(0);
    future_int_f2_count.store(0);

    future_int_f_vector_count.store(0);
    std::vector<future<int> > vf;
    for(std::size_t i = 0; i < 10; ++i)
    {
        vf.push_back(dataflow(&future_int_f1, make_ready_future()));
    }
    future<int> f5 = dataflow(&future_int_f_vector, boost::ref(vf));

    HPX_TEST_EQ(f5.get(), 10);
}
开发者ID:pra85,项目名称:hpx,代码行数:59,代码来源:local_dataflow.cpp

示例6: init_globals

void init_globals()
{
    // Retrieve command line using the Boost.ProgramOptions library.
    boost::program_options::variables_map vm;
    if (!hpx::util::retrieve_commandline_arguments(get_commandline_options(), vm))
    {
        HPX_THROW_EXCEPTION(hpx::commandline_option_error,
            "fibonacci_futures_distributed",
            "failed to handle command line options");
        return;
    }

    boost::uint64_t n = vm["n-value"].as<boost::uint64_t>();

    threshold = vm["threshold"].as<unsigned int>();
    if (threshold < 2 || threshold > n) {
        HPX_THROW_EXCEPTION(hpx::commandline_option_error,
            "fibonacci_futures_distributed",
            "wrong command line argument value for option 'threshold', "
            "should be in between 2 and n-value, value specified: " +
                std::to_string(threshold));
        return;
    }

    distribute_at = vm["distribute-at"].as<unsigned int>();
    if (distribute_at < 2 || distribute_at > n) {
        HPX_THROW_EXCEPTION(hpx::commandline_option_error,
            "fibonacci_futures_distributed",
            "wrong command line argument value for option 'distribute-at', "
            "should be in between 2 and n-value, value specified: " +
                std::to_string(distribute_at));
        return;
    }

    here = hpx::find_here();
    next_locality.store(0);
    serial_execution_count.store(0);

    // try to more evenly distribute the work over the participating localities
    std::vector<hpx::id_type> locs = hpx::find_all_localities();
    std::size_t num_repeats = vm["loc-repeat"].as<int>();

    localities.push_back(here);      // add ourselves
    for (std::size_t j = 0; j != num_repeats; ++j)
    {
        for (std::size_t i = 0; i != locs.size(); ++i)
        {
            if (here == locs[i])
                continue;
            localities.push_back(locs[i]);
        }
    }
}
开发者ID:7ev3n,项目名称:hpx,代码行数:53,代码来源:fibonacci_futures_distributed.cpp

示例7: get_and_reset_value

 inline T get_and_reset_value(boost::atomic<T>& value, bool reset)
 {
     T result = value.load();
     if (reset)
         value.store(0);
     return result;
 }
开发者ID:atrantan,项目名称:hpx,代码行数:7,代码来源:get_and_reset_value.hpp

示例8: CloseDevice

    //! デバイスを閉じる
	void CloseDevice() {
		terminated_.store(true);
		process_thread_.join();
		waveOutReset(hwo_);
		waveOutClose(hwo_);

        //! waveOutResetを呼び出したあとで
        //! WAVEHDRの使用済み通知が来ることがある。
        //! つまり、waveOutResetを呼び出した直後に
        //! すぐにWAVEHDRを解放できない(デバイスによって使用中かもしれないため)
        //! そのため、確実にすべてのWAVEHDRの解放を確認する。
		for( ; ; ) {
			int left = 0;
			for(auto &header : headers_ | boost::adaptors::indirected) {
				if(header.get()->dwUser == WaveHeader::DONE) {
					waveOutUnprepareHeader(hwo_, header.get(), sizeof(WAVEHDR));
					header.get()->dwUser = WaveHeader::UNUSED;
				} else if(header.get()->dwUser == WaveHeader::USING) {
					left++;
				}
			}

			if(!left) { break; }
			Sleep(10);
		}
		hwo_ = NULL;
	}
开发者ID:HatsuneMiku,项目名称:VstHostDemo,代码行数:28,代码来源:WaveOutProcessor.hpp

示例9: run

    void run(void)
    {
        BOOST_WARN(stk.is_lock_free());

        running.store(true);

        thread_group writer;
        thread_group reader;

        BOOST_REQUIRE(stk.empty());

        for (int i = 0; i != reader_threads; ++i)
            reader.create_thread(boost::bind(&stack_tester::get_items, this));

        for (int i = 0; i != writer_threads; ++i)
            writer.create_thread(boost::bind(&stack_tester::add_items, this));

        using namespace std;
        cout << "threads created" << endl;

        writer.join_all();

        cout << "writer threads joined, waiting for readers" << endl;

        running = false;
        reader.join_all();

        cout << "reader threads joined" << endl;

        BOOST_REQUIRE_EQUAL(data.count_nodes(), 0);
        BOOST_REQUIRE(stk.empty());

        BOOST_REQUIRE_EQUAL(push_count, pop_count);
        BOOST_REQUIRE_EQUAL(push_count, writer_threads * node_count);
    }
开发者ID:pkarasev3,项目名称:ecto,代码行数:35,代码来源:stack_test.cpp

示例10: main

int main(int argc, char* argv[])
{
    accumulator.store(0);

    // Initialize and run HPX
    HPX_TEST_EQ_MSG(hpx::init(argc, argv), 0,
        "HPX main exited with non-zero status");

    return hpx::util::report_errors();
}
开发者ID:41i,项目名称:hpx,代码行数:10,代码来源:apply_colocated.cpp

示例11: try_basic_lock

 bool try_basic_lock(thread_id_type current_thread_id)
 {
     if (mtx.try_lock())
     {
         locking_thread_id.exchange(current_thread_id);
         util::ignore_lock(&mtx);
         util::register_lock(this);
         recursion_count.store(1);
         return true;
     }
     return false;
 }
开发者ID:HadrienG2,项目名称:hpx,代码行数:12,代码来源:recursive_mutex.hpp

示例12: test_remote_async_cb

void test_remote_async_cb(hpx::id_type const& target)
{
    typedef hpx::components::client<decrement_server> decrement_client;

    {
        decrement_client dec_f =
            hpx::components::new_<decrement_client>(target);

        call_action call;

        callback_called.store(0);
        hpx::future<std::int32_t> f1 = hpx::async_cb(call, dec_f, &cb, 42);
        HPX_TEST_EQ(f1.get(), 41);
        HPX_TEST_EQ(callback_called.load(), 1);

        callback_called.store(0);
        hpx::future<std::int32_t> f2 =
            hpx::async_cb(hpx::launch::all, call, dec_f, &cb, 42);
        HPX_TEST_EQ(f2.get(), 41);
        HPX_TEST_EQ(callback_called.load(), 1);
    }

    {
        decrement_client dec_f =
            hpx::components::new_<decrement_client>(target);
        hpx::id_type dec = dec_f.get_id();

        callback_called.store(0);
        hpx::future<std::int32_t> f1 =
            hpx::async_cb<call_action>(dec_f, &cb, 42);
        HPX_TEST_EQ(f1.get(), 41);
        HPX_TEST_EQ(callback_called.load(), 1);

        callback_called.store(0);
        hpx::future<std::int32_t> f2 =
            hpx::async_cb<call_action>(hpx::launch::all, dec_f, &cb, 42);
        HPX_TEST_EQ(f2.get(), 41);
        HPX_TEST_EQ(callback_called.load(), 1);
    }
}
开发者ID:khuck,项目名称:hpx,代码行数:40,代码来源:async_cb_remote_client.cpp

示例13: function_pointers

void function_pointers(Executor& exec)
{
    void_f_count.store(0);
    int_f_count.store(0);
    void_f1_count.store(0);
    int_f1_count.store(0);
    int_f2_count.store(0);

    future<void> f1 = dataflow(exec, unwrapped(&void_f1), async(&int_f));
    future<int>
        f2 = dataflow(exec,
            unwrapped(&int_f1)
          , dataflow(exec,
                unwrapped(&int_f1)
              , make_ready_future(42))
        );
    future<int>
        f3 = dataflow(exec,
            unwrapped(&int_f2)
          , dataflow(exec,
                unwrapped(&int_f1)
              , make_ready_future(42)
            )
          , dataflow(exec,
                unwrapped(&int_f1)
              , make_ready_future(37)
            )
        );

    int_f_vector_count.store(0);
    std::vector<future<int> > vf;
    for(std::size_t i = 0; i < 10; ++i)
    {
        vf.push_back(dataflow(exec, unwrapped(&int_f1), make_ready_future(42)));
    }
    future<int> f4 = dataflow(exec, unwrapped(&int_f_vector), std::move(vf));

    future<int>
        f5 = dataflow(exec,
            unwrapped(&int_f1)
          , dataflow(exec,
                unwrapped(&int_f1)
              , make_ready_future(42))
          , dataflow(exec,
                unwrapped(&void_f)
              , make_ready_future())
        );

    f1.wait();
    HPX_TEST_EQ(f2.get(), 126);
    HPX_TEST_EQ(f3.get(), 163);
    HPX_TEST_EQ(f4.get(), 10 * 84);
    HPX_TEST_EQ(f5.get(), 126);
    HPX_TEST_EQ(void_f_count, 1u);
    HPX_TEST_EQ(int_f_count, 1u);
    HPX_TEST_EQ(void_f1_count, 1u);
    HPX_TEST_EQ(int_f1_count, 16u);
    HPX_TEST_EQ(int_f2_count, 1u);
}
开发者ID:Bcorde5,项目名称:hpx,代码行数:59,代码来源:local_dataflow_executor.cpp

示例14: main

int main(int argc, char* argv[])
{
    accumulator.store(0);

    // Initialize and run HPX
    HPX_TEST_EQ_MSG(hpx::init(argc, argv), 0,
        "HPX main exited with non-zero status");

    HPX_TEST_NEQ(boost::uint32_t(-1), locality_id);
    HPX_TEST(on_shutdown_executed || 0 != locality_id);

    return hpx::util::report_errors();
}
开发者ID:NextGenIntelligence,项目名称:hpx,代码行数:13,代码来源:apply_colocated.cpp

示例15: lock

            /// Acquires ownership of the \a recursive_mutex. Suspends the
            /// current HPX-thread if ownership cannot be obtained immediately.
            ///
            /// \throws Throws \a hpx#bad_parameter if an error occurs while
            ///         suspending. Throws \a hpx#yield_aborted if the mutex is
            ///         destroyed while suspended. Throws \a hpx#null_thread_id if
            ///         called outside of a HPX-thread.
            void lock()
            {
                thread_id_type const id = thread_id_from_mutex<Mutex>::call();
                HPX_ASSERT(id != thread_id_from_mutex<Mutex>::invalid_id());

                if (!try_recursive_lock(id))
                {
                    mtx.lock();
                    locking_thread_id.exchange(id);
                    util::ignore_lock(&mtx);
                    util::register_lock(this);
                    recursion_count.store(1);
                }
            }
开发者ID:HadrienG2,项目名称:hpx,代码行数:21,代码来源:recursive_mutex.hpp


注:本文中的boost::atomic::store方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。