0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 18:18:56 +02:00

modules/media/magick: Make greedy use of globals/callbacks; disable their OpenMP threads.

This commit is contained in:
Jason Volk 2019-05-29 04:40:58 -07:00
parent 48c1e30930
commit c1433402c0

View file

@ -72,7 +72,24 @@ ircd::magick::init()
};
::InitializeMagick(nullptr);
::SetLogMethod(handle_log); //XXX assuming global
::SetLogMethod(handle_log);
::SetWarningHandler(handle_warning);
::SetErrorHandler(handle_error);
::SetFatalErrorHandler(handle_fatal);
::SetMagickResourceLimit(ThreadsResource, 1UL);
log::debug
{
log, "resource settings: pixel max:%lu:%lu height:%lu:%lu width:%lu:%lu; threads:%lu:%lu",
::GetMagickResource(PixelsResource),
::GetMagickResourceLimit(PixelsResource),
::GetMagickResource(HeightResource),
::GetMagickResourceLimit(HeightResource),
::GetMagickResource(WidthResource),
::GetMagickResourceLimit(WidthResource),
::GetMagickResource(ThreadsResource),
::GetMagickResourceLimit(ThreadsResource),
};
}
void
@ -157,14 +174,14 @@ return_t
ircd::magick::callex(function&& f,
args&&... a)
{
const auto warning_handler(::SetWarningHandler(handle_warning));
const auto fatal_handler(::SetFatalErrorHandler(handle_fatal));
const auto error_handler(::SetErrorHandler(handle_exception));
const auto error_handler
{
::SetErrorHandler(handle_exception)
};
const unwind reset{[&]
{
::SetFatalErrorHandler(fatal_handler);
::SetErrorHandler(error_handler);
::SetWarningHandler(warning_handler);
}};
::ExceptionInfo ei;
@ -191,16 +208,6 @@ void
ircd::magick::callpf(function&& f,
args&&... a)
{
const auto warning_handler(::SetWarningHandler(handle_warning));
const auto fatal_handler(::SetFatalErrorHandler(handle_fatal));
const auto error_handler(::SetErrorHandler(handle_error));
const unwind reset{[&]
{
::SetFatalErrorHandler(fatal_handler);
::SetErrorHandler(error_handler);
::SetWarningHandler(warning_handler);
}};
if(!call(f, std::forward<args>(a)...))
throw error{};
}
@ -212,16 +219,6 @@ return_t
ircd::magick::call(function&& f,
args&&... a)
{
const auto warning_handler(::SetWarningHandler(handle_warning));
const auto fatal_handler(::SetFatalErrorHandler(handle_fatal));
const auto error_handler(::SetErrorHandler(handle_error));
const unwind reset{[&]
{
::SetFatalErrorHandler(fatal_handler);
::SetErrorHandler(error_handler);
::SetWarningHandler(warning_handler);
}};
return f(std::forward<args>(a)...);
}