MkRuntimeC - The MkRuntimeRLS, a thread-local storage for application-global data … More...
Data Structures | |
struct | MkRuntimeCallbackS |
keep callback related data … More... | |
Macros | |
#define | MK_RT_ATTR_FORMAT_1 __attribute__((format (printf, 1+MK_RT_SHIFT, 2+MK_RT_SHIFT))); |
#define | MK_RT_ATTR_FORMAT_2 __attribute__((format (printf, 2+MK_RT_SHIFT, 3+MK_RT_SHIFT))) |
#define | MK_RT_ATTR_FORMAT_4 __attribute__((format (printf, 4+MK_RT_SHIFT, 5+MK_RT_SHIFT))) |
#define | __MK_ATTR_RT_RUNTIME |
#define | __MK_ATTR_RT_INSTANCE |
#define | __MK_ATTR_INSTANCE |
#define | MK_INSTANCE_HDL(x) |
#define | MK_ATTR_INSTANCE __MK_ATTR_INSTANCE |
#define | MK_ATTR_RT_INSTANCE __MK_ATTR_RT_RUNTIME __MK_ATTR_RT_INSTANCE |
#define | MK_ATTR_STATIC __parser__(static) |
#define | MK_ATTR_RT_STATIC __MK_ATTR_RT_RUNTIME __parser__(static) |
#define | MK_INSTANCE_RT_X(x) |
#define | MK_INSTANCE_RT_XN(x) |
#define | MK_INSTANCE_RT_O(o) |
#define | MK_INSTANCE_RT_ON(o) |
#define | MK_DESTRUCTOR_RT_X(c, x) |
#define | MK_STATIC_RT MkRtSetup_NULL_RT |
Typedefs | |
typedef void(* | MkRuntimeInitF) (MK_RT mkrt) |
additional runtime initialization function … | |
Functions | |
MK_RT | MkRuntimeSetup (MK_RT const mkrt) |
initialize MkRuntimeRLS … | |
void | MkRuntimeCleanup (MK_RT mkrt) |
cleanup MkRuntimeRLS … | |
static MK_RT | MkRuntimeGet (void) |
return a initialized MkRuntimeRLS … | |
static MK_RT | MkRuntimeGetFromObj (MK_OBJ obj) |
return the initialized MkRuntimeRLS from an obj … | |
Variables | |
__thread struct MkRuntimeS | MkRuntimeRLS |
RLS … | |
MkRuntimeCallback | |
Register callback used to setup library-local runtime attributes … Sometimes the features provided by MkRuntimeRLS are not fullfilling the requirements of the implementation. Sometimes the functions provided by the MkRuntimeRLS do not meet the implementation requirements. Two methods are offered to retrofit the missing capability:
| |
typedef struct MkRuntimeCallbackS | MkRuntimeCallbackS |
keep callback related data … | |
size_t | MkRuntimeCallbackAdd (MK_RT mkrt, MkRuntimeCallbackS *cbdata, MkRuntimeInitF rt_callback, MK_STRN ident) |
add a callback to the runtime … | |
void | MkRuntimeCallbackDel (MkRuntimeCallbackS *cbdata) |
delete a callback from the runtime … | |
META_HAS_THREAD | |
#define | MkThreadLocal __thread |
#define | MK_RT_SHIFT 1 |
#define | MK_RT_ARGS_ONLY MK_RT mkrt |
#define | MK_RT_ARGS MK_RT_ARGS_ONLY, |
#define | MK_RT_CALL_ONLY mkrt |
#define | MK_RT_CALL MK_RT_CALL_ONLY, |
#define | MK_RT_CALL_O(o) |
#define | MK_RT_CALL_X(x) |
#define | MK_RT_CALL_NULL_ONLY MkRT |
#define | MK_RT_CALL_NULL MK_RT_CALL_NULL_ONLY, |
#define | MK_RT_NULL NULL, |
#define | MK_RT_PTR mkrt |
#define | MK_RT_REF (*mkrt) |
#define | MK_RT_REF_NULL (MkRuntimeRLS) |
#define | MK_RT_UNUSED MK_UNUSED |
#define | MK_RT_CALL_RT(ptr) |
#define | MK_PARSER_RT_ONLY MK_RT_ARGS_ONLY __parser__(internal,default=N#RUNTIME) |
#define | MK_PARSER_RT MK_PARSER_RT_ONLY, |
MkRtSetup | |
#define | MkRT (&MkRuntimeRLS) |
#define | MkRT_R (MkRuntimeRLS) |
#define | MkRT_O(o) |
#define | MkRT_X(x) |
#define | MkRT_ONN(o) |
#define | MkRT_ON(o) |
#define | MkRT_XN(x) |
#define | MkRtSetup_O(o) |
#define | MkRtSetup_X(x) |
#define | MkRtSetup_XN(x) |
#define | MkRtSetup_ON(o) |
#define | MkRtSetup_NULL MK_RT_UNUSED MK_RT const mkrt = MkRuntimeGet() |
#define | MkRtSetup_RT(r) |
#define | MkRtSetupFromRtExt(rtx) |
#define | MkRtSetup_O_RT(o) |
#define | MkRtSetup_ON_RT(o) |
#define | MkRtSetup_X_RT(x) |
#define | MkRtSetup_XN_RT(x) |
#define | MkRtSetup_NULL_RT if (mkrt == NULL) mkrt = MkRuntimeGet() |
#define | AllRtSetup_O(o) |
#define | AllRtSetup_ON(o) |
#define | AllRtSetup_X(x) |
#define | AllRtSetup_XN(x) |
#define | AllRtSetup_NULL MkRtSetup_NULL |
MkRuntimeC - The MkRuntimeRLS, a thread-local storage for application-global data …
The goal of the runtime-interface is to provide the best performance for thread and non-thread.
configure --enable-threads ...
. configure --disable-threads ...
. MK_RT_*
, MkRt*
or MkRT*
macros. MkThreadLocal struct MkRuntimeS MkRuntimeRLS = {0};
. (&MkRuntimeRLS)
__thread
with thread-support and otherwise to empty
. MkRtSetup_xxx
call after the thread-creation.Always use the
MK_RT_xxx
andMkRtSetup_xxx
macros to get best performane to access the MkRuntimeRLS. Summary: Internal access to the MkRuntimeRLS
threaded storage resolve access MkRtSetup_xxx
speed yes thread-local-storage run-time cache via mkrt fast enough but slower than non-thread no application-global-storage compile-time direct via MkRT fast
The local-cache is only required for a threaded-environment and is defined internal as mkrt variable initialized with a pointer to the MkRuntimeRLS.
do NOT use the mkrt direct because your code will NOT compile in a non-thread environment.
In a runtime-aware function the local-cache is always as first argument in the function.
In a non-runtime-aware method the local-cache is created using the instance-argument:
In a non-runtime-aware static-function the local-cache is created using TLS direct:
In a non-runtime-aware static-function with instance-argument the local-cache is created using instArg:
Summary: In a non-runtime-aware function use the instance to setup the cache-access otherwise MkRtSetup_NULL:
source | local-cache is created with | example | speed |
---|---|---|---|
instance | MkRtSetup_O , MkRtSetup_X | MkRtSetup_X(instance) | fast |
runtime | MkRtSetup_NULL | MkRtSetup_NULL | slow in non-static |
access as | macro | threaded | nothreaded | example | speed |
---|---|---|---|---|---|
reference | MK_RT_REF | (*mkrt) | MkRuntimeRLS | MK_RT_REF.debug | fast if static |
pointer | MK_RT_PTR | mkrt | (&MkRuntimeRLS) | MK_RT_PTR->debug | slow |
args | function definition | function parser extension | function call |
---|---|---|---|
multiple args | MK_RT_ARGS | MK_PARSER_RT | MK_RT_CALL |
no args | MK_RT_ARGS_ONLY | MK_PARSER_RT_ONLY | MK_RT_CALL_ONLY |
MK_RT_ARGS
... and MK_RT_CALL
... and the first argument is no comma.libmkkernel
is mk
,Mk,MK libmqmsgque
is mq
,Mq,MQ liblcconfig
is lc
,Lc,LC libsq3lite
is sq3
,Sq3,SQ3 #define __MK_ATTR_INSTANCE |
Definition at line 866 of file LibMkKernel_mk.h.
#define __MK_ATTR_RT_INSTANCE |
Definition at line 865 of file LibMkKernel_mk.h.
#define __MK_ATTR_RT_RUNTIME |
Definition at line 857 of file LibMkKernel_mk.h.
#define AllRtSetup_NULL MkRtSetup_NULL |
Definition at line 11959 of file LibMkKernel_mk.h.
#define AllRtSetup_O | ( | o | ) |
Definition at line 11955 of file LibMkKernel_mk.h.
#define AllRtSetup_ON | ( | o | ) |
Definition at line 11956 of file LibMkKernel_mk.h.
#define AllRtSetup_X | ( | x | ) |
Definition at line 11957 of file LibMkKernel_mk.h.
#define AllRtSetup_XN | ( | x | ) |
Definition at line 11958 of file LibMkKernel_mk.h.
#define MK_ATTR_INSTANCE __MK_ATTR_INSTANCE |
Definition at line 871 of file LibMkKernel_mk.h.
#define MK_ATTR_RT_INSTANCE __MK_ATTR_RT_RUNTIME __MK_ATTR_RT_INSTANCE |
Definition at line 872 of file LibMkKernel_mk.h.
#define MK_ATTR_RT_STATIC __MK_ATTR_RT_RUNTIME __parser__(static) |
Definition at line 874 of file LibMkKernel_mk.h.
#define MK_ATTR_STATIC __parser__(static) |
Definition at line 873 of file LibMkKernel_mk.h.
#define MK_DESTRUCTOR_RT_X | ( | c, | |
x ) |
Definition at line 881 of file LibMkKernel_mk.h.
#define MK_INSTANCE_HDL | ( | x | ) |
Definition at line 867 of file LibMkKernel_mk.h.
#define MK_INSTANCE_RT_O | ( | o | ) |
Definition at line 879 of file LibMkKernel_mk.h.
#define MK_INSTANCE_RT_ON | ( | o | ) |
Definition at line 880 of file LibMkKernel_mk.h.
#define MK_INSTANCE_RT_X | ( | x | ) |
Definition at line 877 of file LibMkKernel_mk.h.
#define MK_INSTANCE_RT_XN | ( | x | ) |
Definition at line 878 of file LibMkKernel_mk.h.
#define MK_PARSER_RT MK_PARSER_RT_ONLY, |
Definition at line 825 of file LibMkKernel_mk.h.
#define MK_PARSER_RT_ONLY MK_RT_ARGS_ONLY __parser__(internal,default=N#RUNTIME) |
Definition at line 824 of file LibMkKernel_mk.h.
#define MK_RT_ARGS MK_RT_ARGS_ONLY, |
Definition at line 811 of file LibMkKernel_mk.h.
#define MK_RT_ARGS_ONLY MK_RT mkrt |
Definition at line 810 of file LibMkKernel_mk.h.
#define MK_RT_ATTR_FORMAT_1 __attribute__((format (printf, 1+MK_RT_SHIFT, 2+MK_RT_SHIFT))); |
Definition at line 851 of file LibMkKernel_mk.h.
#define MK_RT_ATTR_FORMAT_2 __attribute__((format (printf, 2+MK_RT_SHIFT, 3+MK_RT_SHIFT))) |
Definition at line 852 of file LibMkKernel_mk.h.
#define MK_RT_ATTR_FORMAT_4 __attribute__((format (printf, 4+MK_RT_SHIFT, 5+MK_RT_SHIFT))) |
Definition at line 853 of file LibMkKernel_mk.h.
#define MK_RT_CALL MK_RT_CALL_ONLY, |
Definition at line 813 of file LibMkKernel_mk.h.
#define MK_RT_CALL_NULL MK_RT_CALL_NULL_ONLY, |
Definition at line 817 of file LibMkKernel_mk.h.
#define MK_RT_CALL_NULL_ONLY MkRT |
Definition at line 816 of file LibMkKernel_mk.h.
#define MK_RT_CALL_O | ( | o | ) |
Definition at line 814 of file LibMkKernel_mk.h.
#define MK_RT_CALL_ONLY mkrt |
Definition at line 812 of file LibMkKernel_mk.h.
#define MK_RT_CALL_RT | ( | ptr | ) |
Definition at line 823 of file LibMkKernel_mk.h.
#define MK_RT_CALL_X | ( | x | ) |
Definition at line 815 of file LibMkKernel_mk.h.
#define MK_RT_NULL NULL, |
Definition at line 818 of file LibMkKernel_mk.h.
#define MK_RT_PTR mkrt |
Definition at line 819 of file LibMkKernel_mk.h.
#define MK_RT_REF (*mkrt) |
Definition at line 820 of file LibMkKernel_mk.h.
#define MK_RT_REF_NULL (MkRuntimeRLS) |
Definition at line 821 of file LibMkKernel_mk.h.
#define MK_RT_SHIFT 1 |
Definition at line 809 of file LibMkKernel_mk.h.
#define MK_RT_UNUSED MK_UNUSED |
Definition at line 822 of file LibMkKernel_mk.h.
#define MK_STATIC_RT MkRtSetup_NULL_RT |
Definition at line 884 of file LibMkKernel_mk.h.
#define MkRT (&MkRuntimeRLS) |
Definition at line 11922 of file LibMkKernel_mk.h.
#define MkRT_O | ( | o | ) |
Definition at line 11926 of file LibMkKernel_mk.h.
#define MkRT_ON | ( | o | ) |
Definition at line 11929 of file LibMkKernel_mk.h.
#define MkRT_ONN | ( | o | ) |
Definition at line 11928 of file LibMkKernel_mk.h.
#define MkRT_R (MkRuntimeRLS) |
Definition at line 11923 of file LibMkKernel_mk.h.
#define MkRT_X | ( | x | ) |
Definition at line 11927 of file LibMkKernel_mk.h.
#define MkRT_XN | ( | x | ) |
Definition at line 11930 of file LibMkKernel_mk.h.
#define MkRtSetup_NULL MK_RT_UNUSED MK_RT const mkrt = MkRuntimeGet() |
Definition at line 11944 of file LibMkKernel_mk.h.
#define MkRtSetup_NULL_RT if (mkrt == NULL) mkrt = MkRuntimeGet() |
Definition at line 11953 of file LibMkKernel_mk.h.
#define MkRtSetup_O | ( | o | ) |
Definition at line 11940 of file LibMkKernel_mk.h.
#define MkRtSetup_O_RT | ( | o | ) |
Definition at line 11949 of file LibMkKernel_mk.h.
#define MkRtSetup_ON | ( | o | ) |
Definition at line 11943 of file LibMkKernel_mk.h.
#define MkRtSetup_ON_RT | ( | o | ) |
Definition at line 11950 of file LibMkKernel_mk.h.
#define MkRtSetup_RT | ( | r | ) |
Definition at line 11945 of file LibMkKernel_mk.h.
#define MkRtSetup_X | ( | x | ) |
Definition at line 11941 of file LibMkKernel_mk.h.
#define MkRtSetup_X_RT | ( | x | ) |
Definition at line 11951 of file LibMkKernel_mk.h.
#define MkRtSetup_XN | ( | x | ) |
Definition at line 11942 of file LibMkKernel_mk.h.
#define MkRtSetup_XN_RT | ( | x | ) |
Definition at line 11952 of file LibMkKernel_mk.h.
#define MkRtSetupFromRtExt | ( | rtx | ) |
Definition at line 11946 of file LibMkKernel_mk.h.
#define MkThreadLocal __thread |
Definition at line 808 of file LibMkKernel_mk.h.
typedef struct MkRuntimeCallbackS MkRuntimeCallbackS |
keep callback related data …
typedef void( * MkRuntimeInitF) (MK_RT mkrt) |
additional runtime initialization function …
Every thread get a thread-specifig runtime and this runtime can be initialized with this function.
Definition at line 11988 of file LibMkKernel_mk.h.
size_t MkRuntimeCallbackAdd | ( | MK_RT | mkrt, |
MkRuntimeCallbackS * | cbdata, | ||
MkRuntimeInitF | rt_callback, | ||
MK_STRN | ident ) |
add a callback to the runtime …
The MkRuntimeCallbackAdd and MkRuntimeCallbackDel belong to the low-level-api and is primary used for language-integration into the Programming-Language-Micro-Kernel (PLMK).
The rt_callback is used to initialize local runtime-attributes per thread. This initialization is used to do the following tasks:
Every type is "thread-local" because every type has the type-(thread)-local memory-allocator located at MkTypeS::objalloc→MkAllocDefS::alloc_data and the type-local alloc-callbacks :
The memory-allocator is thread-local because the cache is thread-local including the predefined objects.
read more at MkTypeCreate
NS(...)
macro create a proper function-name in the .dll/.so file 000000000000caef t jvmkkernel_sMkRuntimeCallback 00000000000259a0 b jvmkkernel_sMkRuntimeCallbackData
[in] | cbdata | (non NULL ) - struc to register the callback.
|
[in] | mkrt | (non NULL ) - initial MkRuntimeC.
|
[in] | rt_callback | (non NULL ) - callback to initialize new custom runtime string to identify the rt_callback runtime. |
[in] | ident | (non NULL ) - string to identify the rt_callback runtime. |
0 <= rtId < #MkExtension_size
void MkRuntimeCallbackDel | ( | MkRuntimeCallbackS * | cbdata | ) |
delete a callback from the runtime …
void MkRuntimeCleanup | ( | MK_RT | mkrt | ) |
cleanup MkRuntimeRLS …
Do not call this function directly, because types will be cleared.
Only call this function via MkCleanup.
|
inlinestatic |
return a initialized MkRuntimeRLS …
Definition at line 12162 of file LibMkKernel_mk.h.
return the initialized MkRuntimeRLS from an obj …
Definition at line 12169 of file LibMkKernel_mk.h.
initialize MkRuntimeRLS …
Do not call this function directly, because if MkRuntimeRLS is already initialized, MkRuntimeCleanup will be called first and all libmkkernel types will be cleared.
Only call MkRuntimeGet to get the mkrt and use MkSetup to setup the MkRuntimeRLS.
|
extern |
RLS …
this is the runtime defined as MkThreadLocal