示例#1
0
bool SimpleTableDump::dumpCidVectors(std::string name, atable_ptr_t table) {
  verify(table);
  prepare(name);
  auto store = std::dynamic_pointer_cast<Store>(table);

  std::string fullPath_begin = _baseDirectory + "/" + name + "/begin.cid.dat";
  std::string fullPath_end = _baseDirectory + "/" + name + "/end.cid.dat";
  std::ofstream data_begin(fullPath_begin, std::ios::out | std::ios::binary);
  std::ofstream data_end(fullPath_end, std::ios::out | std::ios::binary);

  // note: The cid vectors are different for NV built and normal, so we better copy it once, instead of accessing the
  // memory underneath directly.
  std::vector<tx::transaction_cid_t> beginCid;
  std::vector<tx::transaction_cid_t> endCid;
  size_t store_size = store->checkpointSize();

  // copy everything to our std::vectors & write out to file
  beginCid.resize(store_size);
  auto cid_start_begin = store->cidBeginIteratorForRecovery();
  std::copy(cid_start_begin, cid_start_begin + store_size, beginCid.begin());
  data_begin.write((char*)&beginCid[0], store_size * sizeof(tx::transaction_cid_t));
  data_begin.close();

  endCid.resize(store_size);
  auto cid_end_begin = store->cidEndIteratorForRecovery();
  std::copy(cid_end_begin, cid_end_begin + store_size, endCid.begin());
  data_end.write((char*)&endCid[0], store_size * sizeof(tx::transaction_cid_t));
  data_end.close();

  return true;
}
示例#2
0
bool smtp_client::send(const mail_message& message,
	const char* email /* = NULL */)
{
	// 发送 SMTP 邮件信封过程
	if (send_envelope(message) == false)
		return false;

	// 优先使用参数给出的邮件文件,然后才是 message 中自动生成的邮件文件
	if (email == NULL)
		email = message.get_email();

	// 如果没有可发送的邮件文件,则认为调用者想通过 write 等接口直接发送数据
	if (email == NULL)
		return true;

	// 发送 DATA 命令
	if (data_begin() == false)
		return false;

	// 发送邮件
	if (send_email(email) == false)
		return false;

	// 发送 DATA 结束符
	return data_end();
}
示例#3
0
void cyclic_read_session::handle_read_tail(
    const boost::system::error_code& error,
    const std::size_t bytes_transferred)
{
  port_read_in_progress_ = false;

  // Check for pending session do_start_extern_stop operation
  if (extern_state::stop == extern_state_)
  {
    if (may_complete_stop())
    {
      complete_stop();
      post_extern_stop_handler();
    }
    return;
  }

  if (error)
  {
    // Check for pending session read operation
    if (extern_read_handler_.has_target())
    {
      extern_read_handler_.post(read_result_type(error, 0));
      return;
    }

    // Store error for the next outer read operation.
    read_error_ = error;
    return;
  }

  typedef boost::asio::streambuf::const_buffers_type        const_buffers_type;
  typedef boost::asio::buffers_iterator<const_buffers_type> buffers_iterator;
  // Extract frame from buffer to distinct memory area
  const_buffers_type committed_buffers(read_buffer_.data());
  buffers_iterator data_begin(buffers_iterator::begin(committed_buffers));
  buffers_iterator data_end(
      data_begin + bytes_transferred - frame_tail_.length());

  frame_ptr new_frame;
  if (frame_buffer_.full())
  {
    new_frame = frame_buffer_.front();
    new_frame->assign(data_begin, data_end);
  }
  else
  {
    new_frame = boost::make_shared<frame>(data_begin, data_end);
  }

  // Consume processed data
  read_buffer_.consume(bytes_transferred);

  // Continue inner operations loop.
  read_until_head();

  // Save ready frame into the cyclic read buffer
  frame_buffer_.push_back(new_frame);

  // If there is waiting read operation - complete it
  if (extern_read_handler_base* handler = extern_read_handler_.target())
  {
    read_result_type copy_result = handler->copy(frame_buffer_);
    frame_buffer_.erase_begin(copy_result.get<1>());
    extern_read_handler_.post(copy_result);
  }
}
示例#4
0
 // Return block as std::string (for debugging), includes eventually cut off
 // elements form the beginning included
 std::string ToString() const {
     return std::string(
         reinterpret_cast<const char*>(data_begin()), size());
 }
示例#5
0
文件: block.cpp 项目: Cyaagain/thrill
std::string PinnedBlock::ToString() const {
    if (!IsValid()) return std::string();
    return std::string(
        reinterpret_cast<const char*>(data_begin()), size());
}