English 中文(简体)
• 管理io——在另一个透镜中服务,除例外情况外,还存在问题
原标题:Managing io_service in another thread, weird problem with exceptions

在我提出申请时,我一直在努力解决这一问题,因此,我试图用简单的法典来复制这个问题。

我正在使用SP窗口1.44和44.4.1版。

我预期以下方案的结果是:

>messageservice.exe

[debug]BEFORE EXCEPTION ****
[error]EXCEPTION HANDLED ****
[debug]AFTER TRY/CATCH
>

但在实践中,有时会发生这种情况,有时会突然发生“无双管得起”的例外情况。

因此,我失去了这样做的原因。

如果我排除了审判权,方案就会被罚款。

该守则是:

#include <iostream>
#include <string>

#include <boost/asio.hpp>
#include <boost/thread.hpp>


#define L_(lvl) std::cout<<"
["<<#lvl<<"]"


void nothingfun() { } /* an empty job */

void threadfun() {
    boost::asio::io_service myIoService; /* thread s own io_service object */

    for(int i=0;i<10000;i++) {
        myIoService.post(&nothingfun);
    }
}


int main()
{
    boost::thread t(&threadfun);


    L_(debug)<<"BEFORE EXCEPTION ****";
    try{
         throw "aaah!";
    } catch(...) {
        L_(error)<<"EXCEPTION HANDLED ****";
    }
    L_(debug)<<"AFTER TRY/CATCH";

    t.join();

    return 0;
}

在一个非主线上管理奥恩-服务公司是否是非法的? 或者我做了一些明显错误的事情吗?

给予任何帮助!

增 编

问题回答

由于Mattin Gruenke的解决方案(http://news.gmane.org/gmane.comp.lib.boost.asio.user)

Apparently having thread safe exceptions is an optional extra in mingw. I needed to specify the -mthreads option when linking

我认为,这应该是永远的核心保障!





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签