duangan4070
2018-12-21 20:09
浏览 106
已采纳

在golang中优先使用goroutine

I'm writing a low latency network, high throughput server in golang. It has acceptor in the main goroutine (which accepts incoming connections). And it passes the incoming connections to 'n' number of worker goroutines.

In this case, to not drop connections, I want the acceptor goroutine to be prioritized over other goroutines so that connections won't be dropped. Or atleast this acceptor goroutine should not get evicted by other worker goroutines.

How can I ensure this?

图片转代码服务由CSDN问答提供 功能建议

我正在用golang编写低延迟网络,高吞吐量服务器。 它在主goroutine中具有接受器(接受传入连接)。 它将传入的连接传递给'n'个工作程序goroutine。

在这种情况下,为了不丢失连接,我希望接受器goroutine优先于其他goroutine,以便赢得连接 不会被丢弃。 或者,至少该接受者goroutine不应被其他工作程序goroutine赶走。

如何确保这一点?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题