MeshLib C Docs
Loading...
Searching...
No Matches
MRProtectedRun.h File Reference
#include <MRCMisc/common.h>
#include <MRCMisc/exports.h>

Go to the source code of this file.

Typedefs

typedef struct MR_std_function_void MR_std_function_void

Functions

MRC_API MR_expected_void_std_stringMR_protectedRun (const MR_std_function_void *task)
MRC_API MR_std_function_voidMR_protectedFunc (MR_PassBy unprotectedFunc_pass_by, MR_std_function_void *unprotectedFunc)

Typedef Documentation

◆ MR_std_function_void

Stores a functor of type: void(void). Possibly stateful. Supported MR_PassBy modes: MR_PassBy_DefaultConstruct, MR_PassBy_Copy, MR_PassBy_Move (and MR_PassBy_DefaultArgument and MR_PassBy_NoObject if supported by the callee).

Function Documentation

◆ MR_protectedFunc()

MRC_API MR_std_function_void * MR_protectedFunc ( MR_PassBy unprotectedFunc_pass_by,
MR_std_function_void * unprotectedFunc )

returns a function, which executes protectedRun( unprotectedFunc ), logging a possible exception but always returning For example, executing in Release configuration the following line does not terminate the program: std::thread( protectedFunc( []() { throw std::runtime_error( "Ops" ); } ) ).join(); Generated from function MR::protectedFunc. Never returns null. Returns an instance allocated on the heap! Must call MR_std_function_void_Destroy() to free it when you're done using it.

◆ MR_protectedRun()

MRC_API MR_expected_void_std_string * MR_protectedRun ( const MR_std_function_void * task)

in Debug configuration: simply executes given task, returns no error; in Release configuration: executes given task inside C++ try-catch block, returns exception's info as error string; on Windows it also catches structured exceptions (SEH) Generated from function MR::protectedRun. Parameter task can not be null. It is a single object. Never returns null. Returns an instance allocated on the heap! Must call MR_expected_void_std_string_Destroy() to free it when you're done using it.