首页 \ 问答 \ 配置Jetty接受器线程(Configuring Jetty Acceptor Threads)

配置Jetty接受器线程(Configuring Jetty Acceptor Threads)

可以配置jetty中的acceptor线程数吗? 默认情况下,accpetor线程的数量是机器中核心数的两倍吗? 根据文档,接受器线程在等待请求时进入阻塞状态。 没有请求(在阻塞状态下)有多个接受器线程有问题吗?


Is possible to configure the number of acceptor threads in jetty? Is the number of accpetor threads twice the number of cores in the machine by default? According to the documentation acceptor thread goes to a blocked state when it is waiting requests. Does having many acceptors threads without requests(In blocked state) a problem?


原文:https://stackoverflow.com/questions/42010220
更新时间:2023-07-14 22:07

最满意答案

boost::asio::buffer_cast<>()是你应该用来访问缓冲区使用的指针。 boost::asio::buffer_size()是你应该用来访问所用大小的东西。

例如

const std::string test("test");
const size_t len = std::min(boost::asio::buffer_size(mybuf), test.length());
memcpy(boost::asio::buffer_cast<void *>(mybuf),
    test.c_str(),
    len);
const std::string test2("test");
boost::asio::mutable_buffer offset = mybuf + len;
const size_t len2 = std::min(boost::asio::buffer_size(offset), test2.length());
memcpy(boost::asio::buffer_cast<void *>(offset),
    test.c_str(),
    len2);

boost::asio::mutable_buffer offset2 = offset + len2;

也可以看看:


boost::asio::buffer_cast<>() is what you should use to get access to the pointer used by the buffer. boost::asio::buffer_size() is what you should use to get access to the size used.

e.g.

const std::string test("test");
const size_t len = std::min(boost::asio::buffer_size(mybuf), test.length());
memcpy(boost::asio::buffer_cast<void *>(mybuf),
    test.c_str(),
    len);
const std::string test2("test");
boost::asio::mutable_buffer offset = mybuf + len;
const size_t len2 = std::min(boost::asio::buffer_size(offset), test2.length());
memcpy(boost::asio::buffer_cast<void *>(offset),
    test.c_str(),
    len2);

boost::asio::mutable_buffer offset2 = offset + len2;

See also:

相关问答

更多
  • Alex,你了解asio异步操作错误。 你的问题是关于缓冲区和套接字的生命周期。 缓冲区必须处于活动状态并且在整个传输时间内打开套接字(从asio::async_write调用到handle_write回调将由Asio io_service调度程序调用。为了更好地理解它是如何工作的,请考虑每次进行一些boost::asio::async_{operation}你发布了指向操作数据的指针和指向作业队列的回调函数的指针。它是Asio决定何时执行你的工作(当然它试图尽可能快地做到这一点=) )。 当整个(可能很大 ...
  • 文件似乎缺乏 boost-asio中 投票最高的问题是关于文档,从那里开始:-) 有人可以帮我调试这个编译错误吗? write() free函数需要一个引用类型作为第一个参数。 不是你的例子中的指针 bool sendMessage(tcp::socket* sock, uint16_t opcode, void* data) { void* fullData = malloc(sizeof(uint16_t) + sizeof(data)); memcpy(fullData, (void* ...
  • 其实我觉得我现在解决了。 1)非ssl上的“握手”确实没有必要,我接受后立即做async_reading 2)而不是async_read/write( socket_.lowest_layer(), ... )我不得不使用socket_.next_layer().async_read_some( buffer, handler)和 async_write( socket_.next_layer(), ... ) 我仍然不知道为什么它不适用于socket_.lowest_layer()(如果有人知道,请解释) ...
  • 尽管写操作是异步的,但这里没有多线程: do_write()在一个线程中被调用。 当然,发送的缓冲区必须处于活动状态且不变,直到调用完成处理程序。 从任何线程调用post()和dispatch()都是安全的。 阅读io_service文档的 “线程安全”部分。 如果async_write正在进行中,并且您再次在同一个套接字上调用async_write ,则未定义数据的发送顺序。 换句话说,数据将被搞砸。 解决此问题的最简单方法是创建消息队列:每次async_write完成时,发出另一个async_write ...
  • 那么根据文档, tcp::socket在多个线程之间共享时不是线程安全的。 因此,您可以像使用boost::mutex建议的那样进行同步,也可以使用async write。 io_service为您服务。 Well according to the documentation tcp::socket is not thread safe when shared between multiple threads. So you either do a synchronisation like you sugg ...
  • 我认为在这种情况下,只有在底层缓冲区已满时才write实际块。 来自msdn的引用在这里是合适的: 成功完成发送功能并不表示数据已成功传送并接收给收件人。 此功能仅表示数据已成功发送。 如果传输系统中没有可用的缓冲区空间来保存要传输的数据,则发送将阻止,除非套接字已置于非阻塞模式。 我尝试写超过64KB(完全从65537开始)并在第一次调用时阻止。 这不是Asio的工作方式,而是TCP和套接字的工作原理。 这个答案也可能有所帮助。 我想你需要明确地从客户端发送收据确认,即滚动你自己的应用层协议。 I thi ...
  • 您需要知道数据的编码方式。 例如,在我的应用程序中,我知道unicode数据是以UTF-8形式出现的,因此我使用函数的普通char版本。 然后我需要将缓冲区视为unicode utf-8数据 - 但是一切都被接收/发送好了。 如果您正在使用不同的字符编码,那么您可能(或可能不会)使用您尝试过的宽字符版本获得更好的语言。 You need to know what encoding your data is coming in as. For example in my applications I know ...
  • boost::asio::buffer_cast<>()是你应该用来访问缓冲区使用的指针。 boost::asio::buffer_size()是你应该用来访问所用大小的东西。 例如 const std::string test("test"); const size_t len = std::min(boost::asio::buffer_size(mybuf), test.length()); memcpy(boost::asio::buffer_cast(mybuf), tes ...
  • 1)是正确的,以及2)工作的原因。 这里不需要互斥锁,因为main和客户端处理程序线程之间的同步是通过io_service::post方法完成的。 post实际上并没有执行任何操作,只是向回调处理程序添加了一个回调(绑定方法),回调处理程序是执行io_service::run的线程,这样的std :: deque只能由运行io_service::run的一个线程访问。 3)这是线程安全,异常安全和所有权的问题。 关于线程安全,您需要100%确定在您调用write只有一个线程将访问指针指向的字符串。 所有权和 ...
  • 这是多线程问题的结果。 对于大多数Boost.Asio对象,在对象上挂起多个异步操作是安全的。 它只是指定对象的并发调用是不安全的。 然而,它通常不会在某些类型上出现问题,例如ip::tcp::socket 。 但是, ssl::stream强调: 应用程序还必须确保所有异步操作都在同一个隐式或显式链中执行。 在您的情况下,解决方案是使用相同的strand wrap()每个组合操作的完成处理程序。 这将导致在strand中调用所有中间操作 。 有关线程安全性和细微差别细节的更多详细信息,请考虑阅读此答案。 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。