小编Rob*_*Lew的帖子

Bazel中的“ @”符号是什么意思?

我目前正在研究Bazel构建系统。我总是在Bazel脚本中看到@符号,但是找不到有关它的任何文档。我在Bazel网站上进行了搜索,但结果似乎没有用。 @在Bazel中。例如:

filegroup(
name = "toolchain_fg",
srcs = [
    ":cc-compiler-amd64",
    "@x86_64_unknown_linux_gnu_gcc_730//:compiler_components",
    ],
)
Run Code Online (Sandbox Code Playgroud)

有人可以在这里为我解释@符号吗?

bazel

4
推荐指数
1
解决办法
833
查看次数

如何使用 boost::beast 检测 websockt 中的断开连接?

我知道我可以使用错误代码async_writeasync_read检查断线。

但是,在我的情况下,收到东西后,我不能立即回信(或者回信可能永远不会发生)。

在读写之间,如何查看客户端掉线异常?

c++ boost websocket boost-beast

3
推荐指数
1
解决办法
1002
查看次数

如何避免派生类提前销毁?

我在基于线程中启动了一个线程。该线程中调用了一个纯虚函数。我在派生类中实现它。

#include <iostream>
#include <memory>
#include <thread>
struct Base {
  std::unique_ptr<std::thread> th;
  virtual void foo() = 0;
  void bar() { 
    th = std::make_unique<std::thread>(
      [this](){
        foo();
      }
    );
  }
  virtual ~Base(){
    th->join();
  }
};

struct Derived : public Base {
  virtual void foo() override {
    std::cout << "impl in derived" << std::endl;
  }
};
int main() {
  Derived d;
  d.bar();
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

但是,在这些代码中,派生对象将在基础对象之前解构。

pure virtual method called
terminate called without an active exception
Aborted (core dumped)
Run Code Online (Sandbox Code Playgroud)

这种情况下如何控制销毁顺序呢?

c++ multithreading

3
推荐指数
1
解决办法
83
查看次数

标签 统计

c++ ×2

bazel ×1

boost ×1

boost-beast ×1

multithreading ×1

websocket ×1