- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm working on a critical system that needs to be able to catch and handle win32 structured exceptions. In order to do this i need to install an exception handler into every thread using_set_se_translator (seehttp://msdn.microsoft.com/en-us/library/5z4bw5h5(VS.80).aspx).
What would be the best way to install such an handler into the internal tbb threads?
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Check out tbb::task_scheduler_observer::on_scheduler_entry() in task_scheduler_observer.h, it's what you need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thetask_scheduler_observer never seems to be called. What am I doing wrong?
EDIT: Added to main
[cpp]class Win32HandlerInstaller : public tbb::task_scheduler_observer { public: Win32HandlerInstaller() { observe(true); } void on_scheduler_entry( bool is_worker ) { Win32Exception::InstallHandler(); CASPAR_LOG_INFO() << "Started TBB Worker Thread"; } void on_scheduler_exit( bool is_worker ) { CASPAR_LOG_INFO() << "Ended TBB Worker Thread"; } }; int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int) { Win32HandlerInstaller(); tbb::task_scheduler_init tbb_init; Application app; return app.Run(); // Doesnt return until applicaiton ends }[/cpp]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I suspect you must create a bit more long-lived observer:
Win32HandlerInstaller observer;
Win32HandlerInstaller observer;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Myapologies seems like i removed a bit to much of the main code. The main function doesn't return until the application ends.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But anyway Win32HandlerInstaller object is instantly destroyed (even before initialization of the scheduler).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Indeed, I stared blind on it.Embarrassing. Thank you for pointing that out.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page