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


C++ CRITICAL_REGION_LOCAL函数代码示例

本文整理汇总了C++中CRITICAL_REGION_LOCAL函数的典型用法代码示例。如果您正苦于以下问题:C++ CRITICAL_REGION_LOCAL函数的具体用法?C++ CRITICAL_REGION_LOCAL怎么用?C++ CRITICAL_REGION_LOCAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: _dbg2

void connection_basic::sleep_before_packet(size_t packet_size, int phase,  int q_len) {
	double delay=0; // will be calculated
	do
	{ // rate limiting
		if (m_was_shutdown) { 
			_dbg2("m_was_shutdown - so abort sleep");
			return;
		}

		{ 
			CRITICAL_REGION_LOCAL(	network_throttle_manager::m_lock_get_global_throttle_out );
			delay = network_throttle_manager::get_global_throttle_out().get_sleep_time_after_tick( packet_size );
		}

		delay *= 0.50;
		if (delay > 0) {
            long int ms = (long int)(delay * 1000);
			MTRACE("Sleeping in " << __FUNCTION__ << " for " << ms << " ms before packet_size="<<packet_size); // debug sleep
			boost::this_thread::sleep(boost::posix_time::milliseconds( ms ) );
		}
	} while(delay > 0);

// XXX LATER XXX
	{
	  CRITICAL_REGION_LOCAL(	network_throttle_manager::m_lock_get_global_throttle_out );
		network_throttle_manager::get_global_throttle_out().handle_trafic_exact( packet_size ); // increase counter - global
	}

}
开发者ID:anonimal,项目名称:bitmonero,代码行数:29,代码来源:connection_basic.cpp

示例2: CRITICAL_REGION_LOCAL

void connection_basic::set_rate_down_limit(uint64_t limit) {
	{
	  CRITICAL_REGION_LOCAL(	network_throttle_manager::m_lock_get_global_throttle_in );
		network_throttle_manager::get_global_throttle_in().set_target_speed(limit);
	}

	{
	  CRITICAL_REGION_LOCAL(	network_throttle_manager::m_lock_get_global_throttle_inreq );
		network_throttle_manager::get_global_throttle_inreq().set_target_speed(limit);
	}
    save_limit_to_file(limit);
}
开发者ID:anonimal,项目名称:bitmonero,代码行数:12,代码来源:connection_basic.cpp

示例3: CRITICAL_REGION_LOCAL

void connection_basic::save_limit_to_file(int limit) {
    // saving limit to file
    if (!epee::net_utils::data_logger::m_save_graph)
        return;

    {
        CRITICAL_REGION_LOCAL(        network_throttle_manager::m_lock_get_global_throttle_out );
        epee::net_utils::data_logger::get_instance().add_data("upload_limit", network_throttle_manager::get_global_throttle_out().get_target_speed() / 1024);
    }

    {
        CRITICAL_REGION_LOCAL(        network_throttle_manager::m_lock_get_global_throttle_in );
        epee::net_utils::data_logger::get_instance().add_data("download_limit", network_throttle_manager::get_global_throttle_in().get_target_speed() / 1024);
    }
}
开发者ID:ifzz,项目名称:bitmonero,代码行数:15,代码来源:connection_basic.cpp

示例4: CRITICAL_REGION_LOCAL

  //---------------------------------------------------------------------------------
  //proper tx_pool handling courtesy of CryptoZoidberg and Boolberry
  bool tx_memory_pool::remove_stuck_transactions()
  {
    CRITICAL_REGION_LOCAL(m_transactions_lock);
    for(auto it = m_transactions.begin(); it!= m_transactions.end();)
    {
      uint64_t tx_age = time(nullptr) - it->second.receive_time;

      if((tx_age > CRYPTONOTE_MEMPOOL_TX_LIVETIME && !it->second.kept_by_block) || 
         (tx_age > CRYPTONOTE_MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME && it->second.kept_by_block) )
      {
        LOG_PRINT_L1("Tx " << it->first << " removed from tx pool due to outdated, age: " << tx_age );
        remove_transaction_keyimages(it->second.tx);
        auto sorted_it = find_tx_in_sorted_container(it->first);
        if (sorted_it == m_txs_by_fee.end())
        {
          LOG_PRINT_L1("Removing tx " << it->first << " from tx pool, but it was not found in the sorted txs container!");
        }
        else
        {
          m_txs_by_fee.erase(sorted_it);
        }
        m_transactions.erase(it++);
      }else
        ++it;
    }
    return true;
  }
开发者ID:newmight2015,项目名称:bitmonero,代码行数:29,代码来源:tx_pool.cpp

示例5: CRITICAL_REGION_LOCAL

	//---------------------------------------------------------------------------------
	bool tx_memory_pool::have_tx(const crypto::hash &id)
	{
		CRITICAL_REGION_LOCAL(m_transactions_lock);
		if (m_transactions.count(id))
			return true;
		return false;
	}
开发者ID:CryptoCoinLabs,项目名称:darknetspace,代码行数:8,代码来源:tx_pool.cpp

示例6: CRITICAL_REGION_LOCAL

bool daemon_backend::generate_wallet(const std::string& path, const std::string& password)
{
  CRITICAL_REGION_LOCAL(m_wallet_lock);
  try
  {
    if (m_wallet->get_wallet_path().size())
    {
      m_wallet->store();
      m_wallet.reset(new tools::wallet2());
    }

    m_wallet->generate(path, password);
  }
  catch (const std::exception& e)
  {
    m_pview->show_msg_box(std::string("Failed to generate wallet: ") + e.what());
    m_wallet.reset(new tools::wallet2());
    return false;
  }

  m_wallet->init(std::string("127.0.0.1:") + std::to_string(m_rpc_server.get_binded_port()));
  update_wallet_info();
  m_last_wallet_synch_height = 0;
  m_pview->show_wallet();
  return true;

}
开发者ID:clintar,项目名称:boolberry-opencl,代码行数:27,代码来源:daemon_backend.cpp

示例7: CRITICAL_REGION_LOCAL

//---------------------------------------------------------------------------------
std::string tx_memory_pool::print_pool(bool short_format)
{
    std::stringstream ss;
    CRITICAL_REGION_LOCAL(m_transactions_lock);
    BOOST_FOREACH(transactions_container::value_type& txe,  m_transactions)
    {
        if(short_format)
        {
            tx_details& txd = txe.second;
            ss << "id: " << txe.first << ENDL
               << "blob_size: " << txd.blob_size << ENDL
               << "fee: " << txd.fee << ENDL
               << "kept_by_block: " << txd.kept_by_block << ENDL
               << "max_used_block_height: " << txd.max_used_block_height << ENDL
               << "max_used_block_id: " << txd.max_used_block_id << ENDL
               << "last_failed_height: " << txd.last_failed_height << ENDL
               << "last_failed_id: " << txd.last_failed_id << ENDL;
        } else
        {
            tx_details& txd = txe.second;
            ss << "id: " << txe.first << ENDL
               <<  obj_to_json_str(txd.tx) << ENDL
               << "blob_size: " << txd.blob_size << ENDL
               << "fee: " << txd.fee << ENDL
               << "kept_by_block: " << txd.kept_by_block << ENDL
               << "max_used_block_height: " << txd.max_used_block_height << ENDL
               << "max_used_block_id: " << txd.max_used_block_id << ENDL
               << "last_failed_height: " << txd.last_failed_height << ENDL
               << "last_failed_id: " << txd.last_failed_id << ENDL;
        }

    }
    return ss.str();
}
开发者ID:Coder420,项目名称:boolberry,代码行数:35,代码来源:tx_pool.cpp

示例8: CRITICAL_REGION_LOCAL

  //-----------------------------------------------------------------------------------------------
  bool core::handle_incoming_tx(const blobdata& tx_blob, tx_verification_context& tvc, bool keeped_by_block)
  {
    tvc = boost::value_initialized<tx_verification_context>();
    //want to process all transactions sequentially
    CRITICAL_REGION_LOCAL(m_incoming_tx_lock);

    if(tx_blob.size() > m_currency.maxTxSize())
    {
      LOG_PRINT_L0("WRONG TRANSACTION BLOB, too big size " << tx_blob.size() << ", rejected");
      tvc.m_verifivation_failed = true;
      return false;
    }

    crypto::hash tx_hash = null_hash;
    crypto::hash tx_prefixt_hash = null_hash;
    Transaction tx;

    if(!parse_tx_from_blob(tx, tx_hash, tx_prefixt_hash, tx_blob))
    {
      LOG_PRINT_L0("WRONG TRANSACTION BLOB, Failed to parse, rejected");
      tvc.m_verifivation_failed = true;
      return false;
    }
    //std::cout << "!"<< tx.vin.size() << std::endl;

    if(!check_tx_syntax(tx))
    {
      LOG_PRINT_L0("WRONG TRANSACTION BLOB, Failed to check tx " << tx_hash << " syntax, rejected");
      tvc.m_verifivation_failed = true;
      return false;
    }

    if(!check_tx_semantic(tx, keeped_by_block))
    {
      LOG_PRINT_L0("WRONG TRANSACTION BLOB, Failed to check tx " << tx_hash << " semantic, rejected");
      tvc.m_verifivation_failed = true;
      return false;
    }

    bool r = add_new_tx(tx, tx_hash, tx_prefixt_hash, tx_blob.size(), tvc, keeped_by_block);
    if(tvc.m_verifivation_failed) {
      if (!tvc.m_tx_fee_too_small) {
        LOG_PRINT_RED_L0("Transaction verification failed: " << tx_hash);
      } else {
        LOG_PRINT_L0("Transaction verification failed: " << tx_hash);
      }
    } else if(tvc.m_verifivation_impossible) {
      LOG_PRINT_RED_L0("Transaction verification impossible: " << tx_hash);
    }

    if (tvc.m_added_to_pool) {
      LOG_PRINT_L1("tx added: " << tx_hash);
      poolUpdated();
    }

    return r;
  }
开发者ID:notegold,项目名称:notegold_XNG,代码行数:58,代码来源:cryptonote_core.cpp

示例9: LOG_PRINT_L2

  //-----------------------------------------------------------------------------------------------
  //bool core::get_outs(uint64_t amount, std::list<crypto::public_key>& pkeys)
  //{
  //  return m_blockchain_storage.get_outs(amount, pkeys);
  //}
  //-----------------------------------------------------------------------------------------------
  bool core::add_new_tx(const Transaction& tx, const crypto::hash& tx_hash, const crypto::hash& tx_prefix_hash, size_t blob_size, tx_verification_context& tvc, bool keeped_by_block) {
    if (m_blockchain_storage.have_tx(tx_hash)) {
      LOG_PRINT_L2("tx " << tx_hash << " is already in blockchain");
      return true;
    }

    // It's not very good to lock on m_mempool here, because it's very hard to understand the order of locking
    // tx_memory_pool::m_transactions_lock, blockchain_storage::m_blockchain_lock, and core::m_incoming_tx_lock
    CRITICAL_REGION_LOCAL(m_mempool);
    if (m_mempool.have_tx(tx_hash)) {
      LOG_PRINT_L2("tx " << tx_hash << " is already in transaction pool");
      return true;
    }

    return m_mempool.add_tx(tx, tx_hash, blob_size, tvc, keeped_by_block);
  }
开发者ID:notegold,项目名称:notegold_XNG,代码行数:22,代码来源:cryptonote_core.cpp

示例10: CRITICAL_REGION_LOCAL

  //---------------------------------------------------------------------------------
  std::string tx_memory_pool::print_pool(bool short_format)
  {
    std::stringstream ss;
    CRITICAL_REGION_LOCAL(m_transactions_lock);
    BOOST_FOREACH(transactions_container::value_type& txe,  m_transactions)
    {
      if(short_format)
      {
        tx_details& txd = txe.second;
        ss << "id: " << txe.first << ENDL
          << "blob_size: " << txd.blob_size << ENDL
          << "fee: " << txd.fee << ENDL
          << "kept_by_block: " << (txd.kept_by_block ? "true":"false") << ENDL
          << "max_used_block_height: " << txd.max_used_block_height << ENDL
          << "max_used_block_id: " << txd.max_used_block_id << ENDL
          << "last_failed_height: " << txd.last_failed_height << ENDL
          << "last_failed_id: " << txd.last_failed_id << ENDL
          << "live_time: " << epee::misc_utils::get_time_interval_string(time(nullptr) - txd.receive_time) << ENDL;
      }else
      {
        tx_details& txd = txe.second;
        ss << "id: " << txe.first << ENDL
          <<  obj_to_json_str(txd.tx) << ENDL
          << "blob_size: " << txd.blob_size << ENDL
          << "fee: " << txd.fee << ENDL
          << "kept_by_block: " << (txd.kept_by_block ? "true":"false") << ENDL
          << "max_used_block_height: " << txd.max_used_block_height << ENDL
          << "max_used_block_id: " << txd.max_used_block_id << ENDL
          << "last_failed_height: " << txd.last_failed_height << ENDL
          << "last_failed_id: " << txd.last_failed_id << ENDL
          << "live_time: " << epee::misc_utils::get_time_interval_string(time(nullptr) - txd.receive_time) << ENDL;
      }

    }
    return ss.str();
  }
开发者ID:aradeshworking,项目名称:boolberry,代码行数:37,代码来源:tx_pool.cpp


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