多线程 gSOAP 服务
有没有办法让存根/骨架编译器生成线程服务(即通过为每个请求生成一个线程或通过线程池)或者我是否必须手动添加soap_copy(),pthread_create()...
我知道--根据常见问题解答和用户指南 7.2.4——gSOAP 是线程安全的并且支持多线程服务。但是,使用soapcpp2 -i 标志我最终得到
int DummyService::run(int port)
{
if (soap_valid_socket(bind(NULL, port, 100)))
{
for (;;)
{
if (!soap_valid_socket(accept()))
return this->error;
(void)serve();
soap_destroy(this);
soap_end(this);
}
}
else
return this->error;
return SOAP_OK;
}
任何提示?
Is there a way for the stub/skeleton compiler to generate threaded services (i.e. by spawning a thread for each request or by thread pooling) or do I have to manually add soap_copy(), pthread_create() ...
I know that -- according to the FAQ and user guide 7.2.4 -- gSOAP is thread safe and does support multi-threaded services. However, using the soapcpp2 -i flag I end up with
int DummyService::run(int port)
{
if (soap_valid_socket(bind(NULL, port, 100)))
{
for (;;)
{
if (!soap_valid_socket(accept()))
return this->error;
(void)serve();
soap_destroy(this);
soap_end(this);
}
}
else
return this->error;
return SOAP_OK;
}
Any hint?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能不是对您的具体请求的直接处理,但它是我能找到的最接近的...(摘自 http://www.cs.fsu.edu/~engelen/soapdoc2.html#sec:mt )
下面的示例说明了使用线程来改进通过在单独的线程中处理新请求来提高服务质量:
注意:代码不会在程序终止时等待线程加入主线程。
在上面链接中引用的文档的同一区域中还有其他线程信息。它至少可以为您寻找解决方案提供一个起点。
This may not be a direct treatment of your specific request, but it is as close as I could find... (clipped from http://www.cs.fsu.edu/~engelen/soapdoc2.html#sec:mt )
The following example illustrates the use of threads to improve the quality of service by handling new requests in separate threads:
Note: the code does not wait for threads to join the main thread upon program termination.
There is additional threading information in the same area of the document referenced in the link above. It may at least provide a starting place in your search for a solution.