javamkkernel 9.0
Loading...
Searching...
No Matches
javamkkernel

The Programming-Language-Micro-Kernel Project.

SYNOPSIS

The javamkkernel package is the implementation of the Programming-Language-Micro-Kernel into the target-language Java.

import javamsgque.mkkernel.*;

The javamkkernel package is a composition of multiple classes defining the Programming-Language-Micro-Kernel:

object description
javamsgque.mkkernel the namespace with all javamkkernel specific definitions
javamsgque.mkkernel.Attribute the interface to access the package specific attribute
javamsgque.mkkernel.MkClassC.Attribute the interface to access the class specific attribute
Instance.Attribute the interface to access the instance specific attribute

To access all features without javamsgque.mkkernel prefix use:

import javamsgque.mkkernel.*;

Using the javamkkernel package …
To access the javamkkernel package the commandline-option --class-path or the environment variable CLASSPYTH have to include the directory.

> man java

--class-path classpath, -classpath classpath, or -cp classpath

      A semicolon (;) separated list of directories, JAR archives, and ZIP archives to search for class files.

      Specifying classpath overrides any setting of the CLASSPATH environment variable.  If the class path option isn't used and classpath isn't set, then the user class path consists of the current directory (.).

      As a special convenience, a class path element that contains a base name of an asterisk (*) is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR .  A Java program can't tell
      the  difference between the two invocations.  For example, if the directory mydir contains a.jar and b.JAR, then the class path element mydir/* is expanded to A.jar:b.JAR, except that the order of JAR files is unspecified.  All .jar
      files in the specified directory, even hidden ones, are included in the list.  A class path entry consisting of an asterisk (*) expands to a list of all the jar files in the current directory.  The  CLASSPATH  environment  variable,
      where  defined, is similarly expanded.  Any class path wildcard expansion that occurs before the Java VM is started.  Java programs never see wildcards that aren't expanded except by querying the environment, such as by calling Sys-
      tem.getenv("CLASSPATH").

JAVA initialization hint

Setup und Cleanup the javamkkernel
Initializing a javamkkernel library depends on the target language and the specific nature of the Programming-Language-Micro-Kernel.
In general it is required to call a Setup style funtion as FIRST argument because of:
  • In a static build the shared library constructor/destructor is NOT called
  • In a shared build the order of library loading is target-language-specific
  • Every executable who uses a meta-library (MkKernel, MqMsgque, LcConfig, ...) which provide a language-specific-type (always assume this) and also support static-build (no constructor is called like C, C++, ...) require a call to the meta-library-setup-function for type-initialization at startup.
If more than one META library is called only the toplevel Setup is required:
  • example: The MkKernelSetup is not required if MqMsgqueSetup or LcConfigSetup is already used.

shared library detail

A new javamkkernel library is initialized with Setup and released again with Cleanup. Both functions are automatically called upon loading and unloading of the shared library.
Example: Definition (C) of the javamkkernel library startup functions
MK_EXTERN void MK_DECL MkSetup (void) __attribute__ ((constructor(200)));
MK_EXTERN void MK_DECL MkCleanup (void) __attribute__ ((destructor(200)));
#define MK_DECL
Definition kernel_mk.h:2159
#define MK_EXTERN
static library
Definition kernel_mk.h:2557
MK_EXTERN void MkCleanup(void)
cleanup javamkkernel internal memory …
MK_EXTERN void MkSetup(void)
setup javamkkernel internal memory …
In the Programming-Language-Micro-Kernel, a type is defined for each thread, which means that the new javamkkernel library must be known when the thread starts. This is not a problem as long as the external javamkkernel library is linked to the application. However, if dlopen is used to load the javamkkernel library, the current restriction is that the new data type from the javamkkernel library has not been defined in all existing threads.
The point in time when a library is loaded depends heavily on the programming language used.
  • A linked language such as C or C++ usually has all libraries initialised at startup.
  • A compiled language such as Java and C# only load a library when a function of the library is used and
    not when the library is declared.
  • A scripting language such as Tcl normally loads the library as soon as the declaration (package require myLib) is made, which happens fairly close to the start of the program but is not guaranteed.

‍To avoid all the problems call the Setup directly at the start of the main program.

Example: Start of the ConfigServer application from the example/csharp directory
  • The problem with the ConfigServer application is that the libmkkernel and libmqmsgque libraries are loaded very early, at startup, and the liblcconfig very late, only on request.
static void Main(string[] argv) {
LcConfig.Setup();
var srv = MqFactoryCT<ConfigServer>.Add().New();
try {
srv.LinkCreate(argv);
srv.ProcessEvent(MqWaitOnEventE.FOREVER);
} catch (Exception e) {
srv.ErrorCatch(e);
}
srv.Exit();
}
To access the javamkkernel package the commandline-option --class-path or the environment variable CLASSPYTH have to include the directory.

> man java

--class-path classpath, -classpath classpath, or -cp classpath

      A semicolon (;) separated list of directories, JAR archives, and ZIP archives to search for class files.

      Specifying classpath overrides any setting of the CLASSPATH environment variable.  If the class path option isn't used and classpath isn't set, then the user class path consists of the current directory (.).

      As a special convenience, a class path element that contains a base name of an asterisk (*) is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR .  A Java program can't tell
      the  difference between the two invocations.  For example, if the directory mydir contains a.jar and b.JAR, then the class path element mydir/* is expanded to A.jar:b.JAR, except that the order of JAR files is unspecified.  All .jar
      files in the specified directory, even hidden ones, are included in the list.  A class path entry consisting of an asterisk (*) expands to a list of all the jar files in the current directory.  The  CLASSPATH  environment  variable,
      where  defined, is similarly expanded.  Any class path wildcard expansion that occurs before the Java VM is started.  Java programs never see wildcards that aren't expanded except by querying the environment, such as by calling Sys-
      tem.getenv("CLASSPATH").

JAVA initialization hint

Setup und Cleanup the javamkkernel
Initializing a javamkkernel library depends on the target language and the specific nature of the Programming-Language-Micro-Kernel.
In general it is required to call a Setup style funtion as FIRST argument because of:
  • In a static build the shared library constructor/destructor is NOT called
  • In a shared build the order of library loading is target-language-specific
  • Every executable who uses a meta-library (MkKernel, MqMsgque, LcConfig, ...) which provide a language-specific-type (always assume this) and also support static-build (no constructor is called like C, C++, ...) require a call to the meta-library-setup-function for type-initialization at startup.
If more than one META library is called only the toplevel Setup is required:
  • example: The MkKernelSetup is not required if MqMsgqueSetup or LcConfigSetup is already used.

shared library detail

A new javamkkernel library is initialized with Setup and released again with Cleanup. Both functions are automatically called upon loading and unloading of the shared library.
Example: Definition (C) of the javamkkernel library startup functions
MK_EXTERN void MK_DECL MkSetup (void) __attribute__ ((constructor(200)));
MK_EXTERN void MK_DECL MkCleanup (void) __attribute__ ((destructor(200)));
In the Programming-Language-Micro-Kernel, a type is defined for each thread, which means that the new javamkkernel library must be known when the thread starts. This is not a problem as long as the external javamkkernel library is linked to the application. However, if dlopen is used to load the javamkkernel library, the current restriction is that the new data type from the javamkkernel library has not been defined in all existing threads.
The point in time when a library is loaded depends heavily on the programming language used.
  • A linked language such as C or C++ usually has all libraries initialised at startup.
  • A compiled language such as Java and C# only load a library when a function of the library is used and
    not when the library is declared.
  • A scripting language such as Tcl normally loads the library as soon as the declaration (package require myLib) is made, which happens fairly close to the start of the program but is not guaranteed.

‍To avoid all the problems call the Setup directly at the start of the main program.

Example: Start of the ConfigServer application from the example/csharp directory
  • The problem with the ConfigServer application is that the libmkkernel and libmqmsgque libraries are loaded very early, at startup, and the liblcconfig very late, only on request.
static void Main(string[] argv) {
LcConfig.Setup();
var srv = MqFactoryCT<ConfigServer>.Add().New();
try {
srv.LinkCreate(argv);
srv.ProcessEvent(MqWaitOnEventE.FOREVER);
} catch (Exception e) {
srv.ErrorCatch(e);
}
srv.Exit();
}

INDEX

BASICS
Philosophy , Package , ManagedObject , PrimitiveTypes , StorageManagement ,
CLASS
MkKernel PACKAGE , MkObjectC , MkBufferC , MkBufferStreamC , MkBufferListC , MkLogFileC , MkErrorC , MkRuntimeC
MISC
BinaryObject, Examples

INTRODUCTION

C-API: MK_C_API - Namespace for the LibMkKernel API …

The LibMkKernel API …

PHILOSOPHY

The MkKernel project is an infrastructure that link an library-item with a Target-Programming-Language using the Programming-Language-Micro-Kernel object-interface. The goal is a programming language independent interface between a C library and a target language.

Philosophy
Write Once → Run Everywhere

The library-item is a c-api for a library available as c-header-file.
The library-item is mapped into a Target-Programming-Language using a language that is supported by the Programming-Language-Micro-Kernel.
Supported Languages are: (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO)

Strategy
It takes 4 years to write a programming-language, but it only takes 4 weeks to insert a micro-kernel.

The library-item is connected to the Target-Programming-Language using an api-layer generated by the token-stream-compiler of the Programming-Language-Micro-Kernel.

Conclusion
The MkKernel-Project is used to manage a collection of library-items using an API that is available in all major programming-languages.

PROGRAMMING

The MkKernel is responsible for:

  • providing the startup and cleanup API
  • providing the memory and caching API
  • providing the logging, debugging and error API
  • providing basic objects like buffer, list, stream, logging, runtime and error

The LibMsgque is separted into three programming-layers:

  1. The foundation-layer, used by the MkKernel library programmer
  2. The kernel-layer, used by the Programming-Language-Micro-Kernel programmer
  3. The implementation-layer, used by the target-language programmer
foundation-layer
The foundation-layer implement the libmkkernel library and is also responsible for the quality-target of the entire project.
  • establishing and managing the library-items
  • memory-management and garbage-collection
  • error-handling
  • logging and debugging
  • written in plain C
kernel-layer
The kernel-layer implement the Programming-Language-Micro-Kernel and is also responsible to generate and maintain the target-language-API source-code.
  • implementation of the managed-object technology
  • implementation of the token-stream-compiler technology
  • written in plain C, TCL and the target-language-API
implementation-layer
The implementation-layer is the API used by the target-language-programmer.
  • written in plain target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO)
Target
!! This documentation describe the implementation-layer and target the Java programmer. !!

PACKAGE

C-API: MkKernel_C_API - The package is the toplevel structure of the Programming-Language-Micro-Kernel

The javamkkernel package is loaded with:

import javamsgque.mkkernel.*;

and is a composition of one or more class-item.

The javamkkernel package add the following public classes into MkObjectC_C_API :

Object C-Type Description
MkObjectC MK_OBJ The MkObjectC object known as obj or object is used as base-object type for a managed-object
MkBufferC MK_BUF The MkBufferC object known as buf or buffer is used to create and manage dynamic, generic, mixed typed data. …
MkBufferStreamC MK_BUS The MkBufferStreamC object known as bus or stream is a subclass of MkBufferC used for package-based-io
MkBufferListC MK_BFL The MkBufferListC object known as bfl or buffer-list is used to create and manage a list of MkBufferC
MkLogFileC MK_LFL The MkLogFileC object known as lfl or log-file is used to control … the target of the logging-output.
MkErrorC MK_ERR The MkErrorC object known as err or error is used to create … and manage an error message …
MkRuntimeC MK_RT The MkRuntimeC class known as mkrt or runtime is the main javamkkernel application environment …

The javamkkernel package add the following public types into MkObjectC_C_API :

    ABSTRACT: MkTypeSTT (TypeTypeType = type of a TypeType)
    |
    |- ABSTRACT: MkDefTypeSTT (TypeType = type of a Type)
       |
       |- MkObjectST, MkLogFileST, MkBufferListST,
       |- MkErrorPanicST, MkErrorIgnoreST, MkErrorPrintST, MkErrorDefaultST, MkErrorST
       |
       |- ABSTRACT: MkBufferST
          |- FINAL: MkBuffer64ST, MkBuffer256ST, MkBuffer1024ST
          |- ABSTRACT: MkBufferStreamST
             | FINAL: MkBufferStream64ST, MkBufferStream256ST, MkBufferStream1024ST, MkBufferStream16384ST

MANAGED OBJECT

C-API: MkObjectC_C_API - The MkObjectC object known as obj or object is used as base-object type for a managed-object

libmqmsgque is also called as Programming-Language-Micro-Kernel. libmqmsgque is like a programming-language without syntax but using the Target-Programming-Language (in our case Java) of the Micro-Kernel as runtime environment.

Integration
To operate as a Micro-Kernel a maximum integration into the Target-Programming-Language is available.

This integration is done using the managed-object-technology.

Managed-Object
A managed-object is a piece of C-Code able to act as a native datatype in all Target-Programming-Languages supported.

The managed object supports low level integration features descripted in MkObjectS :

  • object identification based on signatures
  • reference counting
  • management of the self object pointer for the target-language
  • object-type specific features provided with MkTypeS

In the implementation-layer of javamkkernel only the public-features of the MkObjectC are visible to the programmer.

MANAGED OBJECT TYPES

In Programming-Language-Micro-Kernel everything is a struct, there are type-struct(s) and instance-struct(s):

  1. A type-struct is derived from MkTypeS and provide type-properties (static-properties) and type-methods (slots)
  2. A instance-struct is derived from MkObjectS and provide instance-properties and instance-methods

An instance is full defined by min 4 structs and optional base-structs :

  1. instance-struct -> base-struct(s) -> object-struct (MkObjectS)
  2. instance-type -> base-type(s) -> type-type (MkTypeS)

The following naming-convention exist for the C-API (example: MkBufferC)

name definition
MkBufferS instance-struct → This is the main-struct to define an instance
MkBufferST instance-type as specific-instance-type
MkBufferSTT instance-type as common-instance-type (cast from MkBufferST into MkTypeS) …
MkBufferC_T instance-type as specific-instance-type, useable in a class-macro as: class##_T
MkBufferC_TT instance-type as common-instance-type, useable in a class-macro as: class##_TT
MK_BUF class-shortcut for struct MkBufferS *, all shortcut using the XX_YYY syntax (only for public API) …
MK_BUFR reference-shortcut for struct MkBufferS, all shortcut using the XX_YYYR syntax (only for public API) …
MkBufferCR instance-struct-reference same as struct MkBufferS, useable in a class-macro as: class##R
MkBufferCT_X(instance) cast from an instance into the specific-instance-type
MkBufferCTT_X(instance) cast from an instance into the common-instance-type
MkBufferCT_TT(typ) cast from an common-instance-type into an specific-instance-type
MkBufferCTT instance-type as common-instance-type for MkBufferC in the target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO)
MkBufferCT instance-type as specific-instance-type for MkBufferC in the target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO)

the struct(s) are defined as:

  1. The instance-type is a type-struct able to create an instance.
  2. The type-type is a type-struct not able to create an instance but used as super-class for a instance-type and the base-type
  3. The base-type is a type-struct and used to initialize the type-properties and type-methods (called slots).
    An instance provide methods and slots. A slot is a method predefined in the type like constructor. A list of all slots are defined in MkTypeS.

    example MkBufferC : MkTypeS -> MkDefTypeS -> MkObjectST -> MkBufferST

  4. The instance is a link between the instance-struct, the base-struct the instance-type and the base-type.

    example MkBufferC : MkBufferST -> MkBufferS <- MkObjectS

  5. The base-struct is used to provide the base-instance-properties
    struct MyBaseStruct {
    union {
    struct MkObjectS obj
    } super;
    // MyBaseStruct-properties
    }
    struct MyInstanceStruct {
    union {
    struct MkObjectS obj
    struct MyBaseStruct bse
    } super;
    // MyInstanceStruct-properties
    }
    object header …
    Definition kernel_mk.h:4442

To use the specific-instance-type as argument to a function or as property in a struct the common-instance-type of type MkTypeS is used. To cast a specific-instance-type into a common-instance-type use:

  1. the path: type->super.typ
  2. the shortcut: MkTYP(type)->XYZ (pointer) or MkTYP_R(type).XYZ (reference)

To get the common-instance-type from the instance use:

  1. the path: instance->super.obj.type
  2. the shortcut: MkOBJ(instance)->type (pointer) or MkOBJ_R(instance).type (reference)

To get the base-type from the instance-type use:

  1. the path: instance->super.obj.type->base
  2. the shortcut: MkOBJ(instance)->type->base (pointer) or MkOBJ_R(instance).type->base (reference)

The predefined instance-type is an instance of the default-instance-type (MkDefTypeS) …

struct MkRuntimeS {
...
struct MkDefTypeS _MkBufferST;
...
}
BASE-TYPE all non specific types
Definition kernel_mk.h:4885
The MkRuntimeS provide a per-thread environment for JavaMkKernel …

The properties and slots of the instance-type are predefined by the base-type and may be overwritten …

MkInstanceTypeInit ( MkBufferC, MkObjectC ) ;
#define MkBufferST
instance-type as specific-instance-type …
Definition kernel_mk.h:6255
MK_EXTERN void MkBufferLog_RT(MK_RT const mkrt, MK_BUFN const buf, MK_OBJN fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_INT const lvl)
log the MkBufferC …
MK_EXTERN void MkBufferReset_RT(MK_RT const mkrt, MK_BUF const buf) MK_RT_ATTR_HDL
reset a MkBufferC to the length zero …
MK_EXTERN MK_STRN MkBufferToString_RT(MK_RT const mkrt, MK_BUFN const buf) MK_RT_ATTR_HDL
get the string representation of the buf …
MK_EXTERN MK_BUF MkBufferCopy_RT(MK_RT const mkrt, MK_BUF const buf, MK_BUFN const srce) MK_RT_ATTR_HDL
copy the MkBufferC from srce to dest …
MK_EXTERN void MkBufferDelete_RT(MK_RT const mkrt, MK_BUF const buf) MK_RT_ATTR_HDL
Destructor - delete a MkBufferC instance …
MK_EXTERN MK_BUF MkBufferMerge_RT(MK_RT const mkrt, MK_BUF const buf) MK_RT_ATTR_HDL
Merge-Constructor - create a new MkBufferC as a merge from an existing object …
MK_EXTERN MK_BUF MkBufferDup_RT(MK_RT const mkrt, MK_BUFN const buf) MK_RT_ATTR_HDL
Dup-Constructor - create a new MkBufferC instance as copy from an existing MkBufferC instance
MK_OBJ(* MkMergeF)(MK_RT const mkrt, MK_OBJ const obj)
Definition kernel_mk.h:4603
MK_OBJ(* MkCopyF)(MK_RT const mkrt, MK_OBJ const obj, MK_OBJN const src)
Definition kernel_mk.h:4604
void(* MkLogF)(MK_RT const mkrt, MK_OBJN const obj, MK_OBJ fmt, MK_INT const debug, MK_STRN const prefix, MK_INT const lvl)
Definition kernel_mk.h:4612
MK_OBJ(* MkDupF)(MK_RT const mkrt, MK_OBJ const obj)
Definition kernel_mk.h:4601
void(* MkDestructorF)(MK_RT const mkrt, MK_OBJ const obj)
Definition kernel_mk.h:4600
MK_STRN(* MkToStringF)(MK_RT const mkrt, MK_OBJN const obj)
Definition kernel_mk.h:4614
#define MkTYP_R(x)
cast a known-managed-object into an MkTypeS reference
Definition kernel_mk.h:4879
void(* MkResetF)(MK_RT const mkrt, MK_OBJ const obj)
Definition kernel_mk.h:4605

The following relationship between the three different struct exists:

  1. The instance-type and the type-type have the super-class MkTypeS and the instance not.
  2. The type-type is a super-class of an instance-type.
  3. The instance-type has the 3 attributes MkTypeS::objsig, MkTypeS::objmask and MkTypeS::objsize defined, the type-type not.
  4. The instance has access to the instance-type using the cast (example MkBufferCT_X(instance))
  5. The instance-type has access to the base using MkTypeS::base and to the type using MkObjectS::type.

MANAGED OBJECT PROGRAMMING

The Programming-Language-Micro-Kernel using the manged-object technology to create a class-system with MkObjectS as the root-class.
The MkObjectS is the FIRST and REQUIRED attribute in the super-union.

  1. The instance-type is a composition of one or more super-classes and instance-attributes.
  2. All super-classes are grouped into a annonymous union called super.
  3. Only the super-class struct MkObjectS obj is required for object-management, all other super-classes are optional.
  4. The name of the super-class like obj or buf is fix and is required by tool-macros and functions.
// instance-type: MyFeatureS
struct MyStructS {
// instance super-class
union {
struct MkObjectS obj; // 'object' instance-type (required)
struct MkBufferS buf; // 'buffer' instance-type (optional,example)
} super;
// instance attribute
int myInt; …
}
The ABSTRACT-CLASS used to store a native-type-data-item defined by PRIMITIVE TYPE …
Definition kernel_mk.h:6194

A class is a link (MkObjectS::type) between:

instance-type(example: MkBufferS)
type-type(example: MkBufferSTTMkDefTypeSTTMkTypeSTT)

A class is identified by the signature (MkObjectS::signature) located at the FIRST int32 bits of the class-instance.

  • The managed-object supports one or more super-class using a union with struct MkObjectS obj as the first attribute in the union.
  • The union is required because the managed-object share the memory with the super-class.

There are two possible "cast" operations on a managed-object :

  1. A "cast" from a pointer of unknown origin (example: MK_MNG).
  2. A "cast" from an already known managed object pointer (example: MK_BUS).

In (1) the "cast" is checked using the "signature" and in (2) the "cast" is simply resolved within the "super-class".

Example: "cast" a pointer into a MkBufferS

  • "cast" from an unknown pointer: MK_BUF ret = MkBuf(ptr);
    • This "cast" is called an up-cast because you're upgrading the pointer (getting more information).
    • This "cast" checks the MkObjectS::signature to ensure that ptr is a valid object.
    • This "cast" is checked at runtime.
  • "cast" from a managed pointer: MK_BUF ret = MkBUF(ptr);
    • This "cast" is called a down-cast because you downgrading the pointer (lose some information).
    • This "cast" uses the super-union to just return a pointer that is already available.
    • This "cast" is checked at compile time.
  • To put it simply: MkBuf ≠ MkBUF

Example from kernel_mk.h A full class example from MkBufferS

struct MkBufferS {
// BEGIN-MkBufferS-super - created by 'cls_MqS.tcl -i NHI1_HOME/theKernel/libmkkernel/.libmkkernel.meta' - DO NOT change
union {
struct MkObjectS obj; // base CLASS \MkObjectS
} super;
// END-MkBufferS-super - created by 'cls_MqS.tcl -i NHI1_HOME/theKernel/libmkkernel/.libmkkernel.meta' - DO NOT change
// instance attributes
struct {
MK_NUM cursize;
enum MkTypeE type;
} var;
// instance storage
struct {
union MkBufferU first;
bool doBufferFree;
} storage;
struct ilsS {
} ils;
#define MkBufferS_ils_size 0
};
// BEGIN-MkBufferS-ClassDef - created by 'cls_MqS.tcl -i NHI1_HOME/theKernel/libmkkernel/.libmkkernel.meta' - DO NOT change
// Signature --------------------------------------------------------------
#define MkBufferC_SIGNATURE (MkObjectC_SIGNATURE ^ (1u<<10))
#define MkBufferC_MASK (((1u<<22)-1)<<10)
// Signature --------------------------------------------------------------
#define MkBufferC_X2buf(x) (x)
#define MkBufferC_X2obj(x) MkOBJ(x)
// TypeDef --------------------------------------------------------------
__parser__(ignore) typedef struct MkBufferS MkBufferCR;
__parser__(ignore) typedef const struct MkBufferS MkBufferCNR;
#define MkBufferC_T (&MK_RT_REF._MkBufferC_T)
#define MkBufferC_TT (MkTYP(MkBufferC_T))
#define MkBufferST MkBufferC_T
#define MkBufferSTT (MkTYP(MkBufferST))
#define MkBufferC_type MK_BUF
#define MkBufferCT_X(instance) ( (struct MkDefTypeS *) (MkOBJ_R(instance).type) )
#define MkBufferCTT_X(instance) (MkOBJ_R(instance).type)
#define MkBufferCT_TT(typ) ( (struct MkDefTypeS *) (typ) )
#define MkBufferC_NS MK
#define MkBufferCTT MkBufferCTT
#define MkBufferCT ( (struct MkDefTypeS *) MkBufferCTT )
// TypeCheck --------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes"
__parser__(class=MkBufferC,static,hide)
return MkSanitizeCheck(MkBufferC,mng);
}
#pragma GCC diagnostic pop
#define MkBufferC_Check(mng) MkBufCheck(mng)
// ObjectCast --------------------------------------------------------------
__parser__push__(prefix=Cast);
__parser__(class=MkBufferC,hide,static)
META_ATTRIBUTE_SANITIZE
return (MkBufCheck(mng) ? (MK_BUF)mng : NULL);
}
__parser__(ignore)
META_ATTRIBUTE_SANITIZE
return (MkBufCheck(mng) ? (MK_BUFN)mng : NULL);
}
#define MkBufRaise(_buf) if (!_MkCheckX(MkBufferC,_buf)) { \
MkErrorSetC_1E("'MkBufferC' hdl is NULL"); \
goto error ; \
}
#define MkBUF_R(x) (*(x)).super.buf
#define MkBUF(x) (&MkBUF_R(x))
// END-MkBufferS-ClassDef - created by 'cls_MqS.tcl -i NHI1_HOME/theKernel/libmkkernel/.libmkkernel.meta' - DO NOT change
bool MkBufCheck(MK_MNGN mng)
check MkBufferS%->Mk{ObjectS::signature} …
Definition kernel_mk.h:6286
MK_BUF MkBuf(MK_MNG mng)
cast a unknown-object into an MkBufferS pointer or NULL if not possible
Definition kernel_mk.h:6305
MK_BUFN MkBufN(MK_MNGN mng)
(const) cast a unknown-object into an MkBufferS pointer or NULL if not possible
Definition kernel_mk.h:6312
#define mk_inline
Definition kernel_mk.h:2144
MkTypeE
basic data-types supported by Programming-Language-Micro-Kernel …
Definition kernel_mk.h:3299
const MK_PTRB * MK_MNGN
const - a managed object pointer, datatype will be checked on runtime
Definition kernel_mk.h:2731
int32_t MK_NUM
array size data-type ('num' items in array …
Definition kernel_mk.h:2679
MK_PTRB * MK_MNG
managed object pointer, datatype will be checked on runtime
Definition kernel_mk.h:2728
unsigned char MK_BINB
byte-array type data-type
Definition kernel_mk.h:2706
#define MkSanitizeCheck(_root, _m)
Definition kernel_mk.h:4412
#define MkBufferS_ils_size
ILS size
Definition kernel_mk.h:6217
#define __parser__pop__
Definition kernel_mk.h:318
#define __parser__push__(...)
Definition kernel_mk.h:317
#define __parser__(...)
Definition kernel_mk.h:314
MK_NUM offset
offset from start of MkBufferS to the start of MkBufferS::ils_data
Definition kernel_mk.h:6215
MK_NUM size
size of the MkBufferS::ils_data
Definition kernel_mk.h:6214
struct MkObjectS obj
Definition kernel_mk.h:6197
union MkBufferU first
POINTER to native data representation (ILS or malloc)
Definition kernel_mk.h:6208
struct MkBufferS::ilsS ils
ILS = predefined storage used for MkBufferS::storage->first.
struct MkBufferS::@4 storage
MK_BINB ils_data[MkBufferS_ils_size]
ILS storage
Definition kernel_mk.h:6218
struct MkBufferS::@3 var
variable part of the instance-data
union MkBufferS::@2 super
MK_NUM size
the size of the data-segment
Definition kernel_mk.h:6209
bool doBufferFree
should the data be freed? -> example: pBufferRefInit
Definition kernel_mk.h:6210
a union for all data items supported by MkBufferS …
Definition kernel_mk.h:3435

PRIMITIVE TYPE

C-API: MkKernel_PrimitiveType_C_API - a collection of all native-data-types supported by MkBufferC

The data send from one package-item to an other package-item is focused on speed and usability. By default the data is send as binary, only if the endian changes or a string representation is required an additional transformation is done.
The data send from one package-item to an other package-item is limited to a collection of specific types, based on native C data types.
An javamkkernel-API command with a focus on a specific type is using a type-postfix, for example MqReadC read a (C=string) data from the read-package.
In the documentation the type-item (TT) is a synonym for a (Y,O,S,I,W,F,D,B,C,L,U) type-item.

The following native-type identifier are available:

TT native comment
Y byte 1 byte signed character
O boolean 1 byte boolean value using true or false
S short 2 byte signed short
I int 4 byte signed integer
W long 8 byte signed long long integer
F float 4 byte float
D double 8 byte double
B byte[] unsigned char array used for binary data
C String string data using a \0 at the end

The following compose-type identifier's are available:

TT native comment
U MkBufferC buffer-item that can hold any single typed item from above
L MkBufferListC buffer-list that can hold many buffer-item from above

Every native-data-type is encapsualted into a MkBufferC. A MkBufferC is type safe, this mean that every read to a MkBufferC have to match the data-type of the previous write. One exception is available, the cast from and to the String data-type (TYPE=C) is allowed.

Sending data mean sending one ore more MkBufferC from one package-item to an other package-item. The sender is using a MqSendTT command to put data as MkBufferC into an send-data-package and the reveiver is using a MqReadTT command to retrieve the data from the read-data-package.

CLASS TYPE

C-API: MkKernel_ClassType_C_API - a collection of types using the META class definition …

TODO

POINTER TYPE

C-API: MkKernel_PointerType_C_API - a collection of types allocates as array of data and supported by MkBufferC

For native type support read: MkKernel_PrimitiveType_C_API

The pointer-type is part of the native-type and usually support the size argument to propper allocate storage.

The following pointer-type identifier is available in MkBufferS:

TT type const type comment
B MK_BIN MK_BINN unsigned char array used for binary data (byte[])
C MK_STR MK_STRN string data using a \0 at the end (String)

STORAGE MANAGEMENT

C-API: MkKernel_Storage_C_API - Storage Management …

Storage management is used in javamkkernel to provide temporary storage. It is a common design pattern that javamkkernel only returns a reference to the Internal-Temporary-Storage (ITS), so the Internal-Active-Storage (IAS) is not returned to the external end user. The ITS is a storage that is only used as a return value and nothing else. The temporary in ITS refers exclusively to the current state of the storage and not to the lifespan of the storage, the ITS is only allocated once at startup and then used again and again, similar to the static storage in C.

Internal javamkkernel distinguishes three different storage sources:

Context-Local-Storage (CLS)
CLS is tied to a specific MqContextC.
Example: the MqReadU returns a reference to an internal MkBufferC.
Funktion-Local-Storage (FLS)
FLS is used as the local temporary storage, usually as thread-local-storage, of a function-return-value.
Example: the MqReadL returns a MkBufferListC which is filled with multiple MkBufferC.
Runtime-Local-Storage (RLS)
RLS is used as global storage per RunTime instance.
Example: the MkErrorC only exists ONCE per runtime.

The CLS and FLS have the same visibility to the end user and are explained together as FLS.
The RLS is not mentioned in this documentation section because the RLS is more internal than CLS and FLS.

The end-user uses a FLS reference like a normal local JV variable but with the following restriction:

  1. The value of the variable is a reference to the FLS storage belonging to the method that returned the reference.
  2. A FLS storage only ever exists once in a thread, which means that the FLS storage of a reference is overwritten if the FLS storage is used a second time in the same context.
  3. A context is, for example, a coherent block of code such as in a "service callback". A coherent context is broken if the same method that returned the original FLS as a result is called a second time or if a method is called that uses the "event loop".
  4. FLS storage must NOT be released by the end user, the Programming-Language-Micro-Kernel always ensures that the storage management of javamkkernel and the target-language is synchronized.
  5. If a FLS reference is added to another reference and this reference is also managed by the Programming-Language-Micro-Kernel, the Programming-Language-Micro-Kernel automatically ensures that the storage management is coherent, which means that the end user does not have to do anything.
  6. The FLS reference can be updated. This means that the FLS storage is being updated because the reference owner (usually a local variable) temporarily owns the FLS storage.

The "Dup" (duplicate) function is used to convert a temporary FLS variable into a global storage. The global storage is managed by the end user and may have to be released depending on the target programming language.

Example from server.java "ReadL" overwrite previous "ReadL"

  class BFL2 implements ICallback {
    public void Callback(MqContextC ctx) {
      var tmp1 = ctx.ReadL()                      ; // "tmp1" is now a reference to the FLS storage of "ReadL"
      var tmp2 = ctx.ReadL()                      ; // ERROR: the "tmp2" is using a SHARED reference with "tmp1"
      ctx.Send("R","LL",tmp1,tmp2)                ; // ERROR: "$tmp1" and "$tmp2" are the SAME values
    }
  }

Example from server.java "ReadL" overwrite previous "ReadL" even in an "Event-Loop"

  class pBFL3 implements ICallback {
    private MkBufferListC  tmp2;
    public void Callback(MqContextC ctx) {
      tmp2 = ctx.ReadL()                          ; // ERROR: the "tmp2" is using a SHARED reference with "tmp1"
    }
  }
  class BFL3 implements ICallback {
    public void Callback(MqContextC ctx) {
      var tmp1 = ctx.ReadL()                      ; // "tmp1" is now a reference to the FLS storage of "ReadL"
      Send("C",new pBFL3(),"ECOL:[III]",4,5,6)    ; // ATTENTION: callback "pBFL3" using "ReadL"
      ctx.ProcessEvent(MqWaitOnEventE.OWN)        ; // ERROR: enter event-loop, callback "pBFL3" is called
      ctx.Send("R","L",tmp1)                      ; // ERROR: "$tmp1" has now the value from "$tmp2"
    }
  }

Example from server.java convert "ReadL" result into global storage using "Dup" and free later

  class BFL4 implements ICallback {
    public void Callback(MqContextC ctx) {
      var tmp1 = ctx.ReadL()                      ; // "tmp1" is now a reference to the FLS storage of "ReadL"
      var glb1 = tmp1.Dup()                       ; // OK: "glb1" is now a UNSHARED reference to the global memory
      var tmp2 = ctx.ReadL()                      ; // "tmp2" is now a reference to the FLS storage of "ReadL"
      ctx.Send("R","LL",glb1,tmp2)                ; // OK: "glb1" (alias tmp1) and "tmp2" are separate references
    }
  }

TLS storage used by the *CreateTLS style of functions

In the C language the TLS (Thread-Local-Storage) is unique per definition and the name is used to distinguish the storage.

‍The Problem is to create a TLS interface useable in all target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO) supported by the Programming-Language-Micro-Kernel.

The *CreateTLS style function return a TLS that is unique per runtime and not unique per definition. The tlsid (0,1,2,3...) is used to distinguish the storage.

Note
Every *CreateTLS style function with the same tlsid return the same memory in the same thread.

There is always a risk that the memory used by the *CreateTLS style of functions will also be used by another component of the software in the same thread.

Attention
Use the *CreateTLS style function with caution in a local (controlled) context.
It is a problem if the event-loop is called like for an event or an asynchronous-service-call and if an other component of the software uses the same *CreateTLS style function with the same tlsid .

Example from perfserver.java performance test with TLS storage in a local (controlled) context

  class BUST implements ICallback {
    public void Callback(MqContextC ctx) {
      MkBufferStreamC bus = MkBufferStreamC.CreateTLS(0);
      while (ReadItemExists()) {
        bus.WriteU(ReadU());
      }
      bus.PosToStart();
      SendSTART();
      while (bus.ReadItemExists()) {
        SendU(bus.ReadU());
      }
      SendRETURN();
    }
  }

MkKernel PACKAGE

MkKernel ENUM

enum MkErrorEcollection for the different error-codes …
ErrorE_FromIntreturn the MkErrorE from integer …
ErrorE_ToIntreturn the MkErrorE as integer …
ErrorE_ToStringreturn the MkErrorE as string …
enum MkTimeoutEPredefined Timeout values …
TimeoutE_FromIntreturn the MkTimeoutE from integer …
TimeoutE_ToIntreturn the MkTimeoutE as integer …
TimeoutE_ToStringreturn the MkTimeoutE as string …
enum MkTypeEbasic data-types supported by Programming-Language-Micro-Kernel
TypeE_FromIntreturn the MkTypeE from integer …
TypeE_ToIntreturn the MkTypeE as integer …
TypeE_ToString

return the MkTypeE as string …

MkKernel SETUP

Cleanupcleanup javamkkernel internal memory …
Setup

setup javamkkernel internal memory …

MkKernel DETAIL

C-API: MkKernel_C_API - The package is the toplevel structure of the Programming-Language-Micro-Kernel

The javamkkernel package is loaded with:

import javamsgque.mkkernel.*;

and is a composition of one or more class-item.

The javamkkernel package add the following public classes into MkObjectC_C_API :

Object C-Type Description
MkObjectC MK_OBJ The MkObjectC object known as obj or object is used as base-object type for a managed-object
MkBufferC MK_BUF The MkBufferC object known as buf or buffer is used to create and manage dynamic, generic, mixed typed data. …
MkBufferStreamC MK_BUS The MkBufferStreamC object known as bus or stream is a subclass of MkBufferC used for package-based-io
MkBufferListC MK_BFL The MkBufferListC object known as bfl or buffer-list is used to create and manage a list of MkBufferC
MkLogFileC MK_LFL The MkLogFileC object known as lfl or log-file is used to control … the target of the logging-output.
MkErrorC MK_ERR The MkErrorC object known as err or error is used to create … and manage an error message …
MkRuntimeC MK_RT The MkRuntimeC class known as mkrt or runtime is the main javamkkernel application environment …

The javamkkernel package add the following public types into MkObjectC_C_API :

    ABSTRACT: MkTypeSTT (TypeTypeType = type of a TypeType)
    |
    |- ABSTRACT: MkDefTypeSTT (TypeType = type of a Type)
       |
       |- MkObjectST, MkLogFileST, MkBufferListST,
       |- MkErrorPanicST, MkErrorIgnoreST, MkErrorPrintST, MkErrorDefaultST, MkErrorST
       |
       |- ABSTRACT: MkBufferST
          |- FINAL: MkBuffer64ST, MkBuffer256ST, MkBuffer1024ST
          |- ABSTRACT: MkBufferStreamST
             | FINAL: MkBufferStream64ST, MkBufferStream256ST, MkBufferStream1024ST, MkBufferStream16384ST

MkKernel ENUM

C-API: MkKernel_Enum_C_API - C-API: Internal - Enum definition - javamkkernel enum definition …

MkKernel_C_API

A enum in the Programming-Language-Micro-Kernel is a enum-data-type and 3 enum-access-attributes

  1. ENUM_ToString → return the string-value from the enum-value
  2. ENUM_ToInt → return the integer-value from the enum-value
  3. ENUM_FromInt → create an enum-value from an integer-value.

The enum-data-type and the 3 enum-access-attributes are defined in all target-languages (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO).

enum MkErrorE

TOP

collection for the different error-codes … → API: javamsgque.mkkernel.MkErrorE

This is the default-error-indicator and return-value from near all Programming-Language-Micro-Kernel functions.

enum MkErrorE {
MK_OK = 0,
MK_ERROR = 2,
};
MkErrorE
collection for the different error-codes …
Definition kernel_mk.h:3111
@ MK_ERROR
exit upper code with an error (persistent)
Definition kernel_mk.h:3114
@ MK_CONTINUE
continue with upper code
Definition kernel_mk.h:3113
@ MK_OK
everything is OK, no error available (persistent)
Definition kernel_mk.h:3112

[static] MkErrorE ErrorE_FromInt(int value)

TOP

return the MkErrorE from integer … → API: javamsgque.mkkernel.MkKernel.ErrorE_FromInt

[static] int ErrorE_ToInt(MkErrorE value)

TOP

return the MkErrorE as integer … → API: javamsgque.mkkernel.MkKernel.ErrorE_ToInt

[static] String ErrorE_ToString(MkErrorE value)

TOP

return the MkErrorE as string … → API: javamsgque.mkkernel.MkKernel.ErrorE_ToString


enum MkTimeoutE

TOP

Predefined Timeout values … → API: javamsgque.mkkernel.MkTimeoutE

The MkTimeoutE is used wherever a "timeout" is required. As a special feature, in addition to the defined values in MkTimeoutE, freely defined values as integers as seconds are also accepted.

__parser__(enum-accept-integer=long)
enum MkTimeoutE {
};
MkTimeoutE
Predefined Timeout values …
Definition kernel_mk.h:3155
@ MK_TIMEOUT_LONG
long timeout in sec (180 sec) …
Definition kernel_mk.h:3159
@ MK_TIMEOUT_VERYSHORT
very short timeout in sec (5 sec) …
Definition kernel_mk.h:3168
@ MK_TIMEOUT_INIT
maximum timeout in sec (900 sec) …
Definition kernel_mk.h:3157
@ MK_TIMEOUT_MAX
request the maximum possible (infinite) timeout value …
Definition kernel_mk.h:3174
@ MK_TIMEOUT_NORMAL
normal timeout in sec (90 sec) …
Definition kernel_mk.h:3161
@ MK_TIMEOUT_USER
request the user defined timeout value from the MqTimeout configuration value …
Definition kernel_mk.h:3172
@ MK_TIMEOUT_SOCKET
shorter timeout in sec (10 sec) … This TIMEOUT is used for socket connection with 'connect'
Definition kernel_mk.h:3166
@ MK_TIMEOUT_SHORT
short timeout in sec (20 sec) …
Definition kernel_mk.h:3163
@ MK_TIMEOUT_DEFAULT
request the default timeout value …
Definition kernel_mk.h:3170
#define META_TIMEOUT_REF
Definition kernel_mk.h:194

[static] MkTimeoutE TimeoutE_FromInt(int value)

TOP

return the MkTimeoutE from integer … → API: javamsgque.mkkernel.MkKernel.TimeoutE_FromInt

[static] int TimeoutE_ToInt(MkTimeoutE value)

TOP

return the MkTimeoutE as integer … → API: javamsgque.mkkernel.MkKernel.TimeoutE_ToInt

[static] String TimeoutE_ToString(MkTimeoutE value)

TOP

return the MkTimeoutE as string … → API: javamsgque.mkkernel.MkKernel.TimeoutE_ToString


enum MkTypeE

TOP

basic data-types supported by Programming-Language-Micro-Kernel … → API: javamsgque.mkkernel.MkTypeE

enum MkTypeE {
MK_BINT = ((8 << MK_TYPE_SHIFT) ),
MK_STRT = ((9 << MK_TYPE_SHIFT) ),
MK_LSTT = ((10 << MK_TYPE_SHIFT) ),
};
#define MK_TYPE_IS_8_BYTE
the type is native and has a size of 8 bytes …
Definition kernel_mk.h:3282
#define MK_TYPE_IS_4_BYTE
the type is native and has a size of 4 bytes …
Definition kernel_mk.h:3279
#define MK_TYPE_IS_1_BYTE
the type is native and has a size of 1 byte …
Definition kernel_mk.h:3273
#define MK_TYPE_SHIFT
FIXED: type is only 8bit -> 4 bit=15 for type and 4 bit for flag …
Definition kernel_mk.h:3289
#define MK_TYPE_IS_2_BYTE
the type is native and has a size of 2 bytes …
Definition kernel_mk.h:3276
@ MK_BYTT
Y: 1 byte 'byte' type.
Definition kernel_mk.h:3300
@ MK_WIDT
W: 8 byte 'long long int' type.
Definition kernel_mk.h:3305
@ MK_INTT
I: 4 byte 'int' type.
Definition kernel_mk.h:3303
@ MK_FLTT
F: 4 byte 'float' type.
Definition kernel_mk.h:3304
@ MK_BINT
B: X byte 'byte-array' type.
Definition kernel_mk.h:3307
@ MK_BOLT
O: 1 byte 'boolean' type.
Definition kernel_mk.h:3301
@ MK_DBLT
D: 8 byte 'double' type.
Definition kernel_mk.h:3306
@ MK_STRT
C: X byte 'string' type (e.g. with a \0 at the end)
Definition kernel_mk.h:3308
@ MK_LSTT
L: X byte 'list' type.
Definition kernel_mk.h:3309
@ MK_SRTT
S: 2 byte 'short' type.
Definition kernel_mk.h:3302
See also
TypeE_ToString, TypeE_ToInt, TypeE_FromInt, BufferGetType2, BufferCastTo, BufferStreamReadGetNextType

[static] MkTypeE TypeE_FromInt(int value)

TOP

return the MkTypeE from integer … → API: javamsgque.mkkernel.MkKernel.TypeE_FromInt

[static] int TypeE_ToInt(MkTypeE value)

TOP

return the MkTypeE as integer … → API: javamsgque.mkkernel.MkKernel.TypeE_ToInt

[static] String TypeE_ToString(MkTypeE value)

TOP

return the MkTypeE as string … → API: javamsgque.mkkernel.MkKernel.TypeE_ToString

MkKernel SETUP

C-API: MkKernel_Setup_C_API - Setup und Cleanup the javamkkernel

Initializing a javamkkernel library depends on the target language and the specific nature of the Programming-Language-Micro-Kernel.

In general it is required to call a Setup style funtion as FIRST argument because of:

  • In a static build the shared library constructor/destructor is NOT called
  • In a shared build the order of library loading is target-language-specific
  • Every executable who uses a meta-library (MkKernel, MqMsgque, LcConfig, ...) which provide a language-specific-type (always assume this) and also support static-build (no constructor is called like C, C++, ...) require a call to the meta-library-setup-function for type-initialization at startup.

If more than one META library is called only the toplevel Setup is required:

  • example: The MkKernelSetup is not required if MqMsgqueSetup or LcConfigSetup is already used.

shared library detail

A new javamkkernel library is initialized with Setup and released again with Cleanup. Both functions are automatically called upon loading and unloading of the shared library.

Example: Definition (C) of the javamkkernel library startup functions

MK_EXTERN void MK_DECL MkSetup (void) __attribute__ ((constructor(200)));
MK_EXTERN void MK_DECL MkCleanup (void) __attribute__ ((destructor(200)));

In the Programming-Language-Micro-Kernel, a type is defined for each thread, which means that the new javamkkernel library must be known when the thread starts. This is not a problem as long as the external javamkkernel library is linked to the application. However, if dlopen is used to load the javamkkernel library, the current restriction is that the new data type from the javamkkernel library has not been defined in all existing threads.

The point in time when a library is loaded depends heavily on the programming language used.

  • A linked language such as C or C++ usually has all libraries initialised at startup.
  • A compiled language such as Java and C# only load a library when a function of the library is used and
    not when the library is declared.
  • A scripting language such as Tcl normally loads the library as soon as the declaration (package require myLib) is made, which happens fairly close to the start of the program but is not guaranteed.

‍To avoid all the problems call the Setup directly at the start of the main program.

Example: Start of the ConfigServer application from the example/csharp directory

  • The problem with the ConfigServer application is that the libmkkernel and libmqmsgque libraries are loaded very early, at startup, and the liblcconfig very late, only on request.
static void Main(string[] argv) {
LcConfig.Setup();
var srv = MqFactoryCT<ConfigServer>.Add().New();
try {
srv.LinkCreate(argv);
srv.ProcessEvent(MqWaitOnEventE.FOREVER);
} catch (Exception e) {
srv.ErrorCatch(e);
}
srv.Exit();
}

[static] Cleanup()

TOP

cleanup javamkkernel internal memory … → API: javamsgque.mkkernel.MkKernel.Cleanup

MkCleanup will only be recognized once and will be ignored if not called in the same thread as MkSetup. After a call to MkSetup the call to MkCleanup is possible again.

‍The public MkCleanup is just a placeholder, the internal MkCleanup is always called even if the public MkCleanup is not called.

Attention
during cleanup objects will be deleted too -> the language interpreter have to be active

[static] Setup()

TOP

setup javamkkernel internal memory … → API: javamsgque.mkkernel.MkKernel.Setup

MkSetup will only be recognized once, additional call's will be ignored until a MkCleanup is called.

‍A call to the public MkSetup is required if dlopen and thread is used.


MkObjectC

MkObjectC DBG

DbgMdebug: write a static-marker to the MkLogFileC (default: stderr) …
DbgDumpdebug: Dump a instance to stderr with LNG and MQ internal data…
DbgLdebug: write a instance-marker to the MkLogFileC (default: stderr) using the fmtobj as prefix …
DbgLogCdebug: write a short-obj-summary to MkLogFileC (default: stderr) …
DbgOidebug: write the object-details to MkLogFileC (default: stderr) …
DbgSTACK

debug: write the stack-trace to MkLogFileC (default: stderr) …

MkObjectC INTROSPECTION

Instancesget head-instance from linked-list of MkObjectS type …
Nextget next instance from linked-list of MkObjectS type
Prev

get previous instance from linked-list of MkObjectS type

MkObjectC LOG

LogCwrite a logging-message to MkLogFileC (default: stderr) using the internal format …
LogHEXlog binaray data as HEX into the MkLogFileC (default: stderr) …
LogLog-Slot - log the entire object to the MkLogFileC (default: stderr) target …
LogDetaillog the MkObjectS verbose into the MkLogFileC (default: stderr) …
LogSimple

log the MkObjectS into the MkLogFileC (default: stderr) …

MkObjectC MISC

FromHandleImport-Slot - returns a obj from a former exported handle
ErrorCatchconvert a programming-language-error into an javamkkernel error …
ToErrorError-Slot - return an error-object pre initialized with obj data.
ToHandleExport-Slot - returns a reference to the obj useable for external storage
ToNameInfo-Slot - returns brief information about the obj as a string
ToNameOfClassClass-Slot - returns the JV-Class-Name of the obj as string
ToNameOfTypeType-Slot - returns the LibMkKernel-Type-Name of the obj as a string
ToString

String-Slot - returns the string representation of the obj

MkObjectC TOR

DeleteDelete-Slot - delete an instance.
Dispose

Dispose-Slot - untie the connection between the Native-JV-Instance and the LibMsgque-Instance.

MkObjectC DETAIL

C-API: MkObjectC_C_API - The MkObjectC object known as obj or object is used as base-object type for a managed-object

libmqmsgque is also called as Programming-Language-Micro-Kernel. libmqmsgque is like a programming-language without syntax but using the Target-Programming-Language (in our case Java) of the Micro-Kernel as runtime environment.

Integration
To operate as a Micro-Kernel a maximum integration into the Target-Programming-Language is available.

This integration is done using the managed-object-technology.

Managed-Object
A managed-object is a piece of C-Code able to act as a native datatype in all Target-Programming-Languages supported.

The managed object supports low level integration features descripted in MkObjectS :

  • object identification based on signatures
  • reference counting
  • management of the self object pointer for the target-language
  • object-type specific features provided with MkTypeS

In the implementation-layer of javamkkernel only the public-features of the MkObjectC are visible to the programmer.

MANAGED OBJECT TYPES

In Programming-Language-Micro-Kernel everything is a struct, there are type-struct(s) and instance-struct(s):

  1. A type-struct is derived from MkTypeS and provide type-properties (static-properties) and type-methods (slots)
  2. A instance-struct is derived from MkObjectS and provide instance-properties and instance-methods

An instance is full defined by min 4 structs and optional base-structs :

  1. instance-struct -> base-struct(s) -> object-struct (MkObjectS)
  2. instance-type -> base-type(s) -> type-type (MkTypeS)

The following naming-convention exist for the C-API (example: MkBufferC)

name definition
MkBufferS instance-struct → This is the main-struct to define an instance
MkBufferST instance-type as specific-instance-type
MkBufferSTT instance-type as common-instance-type (cast from MkBufferST into MkTypeS) …
MkBufferC_T instance-type as specific-instance-type, useable in a class-macro as: class##_T
MkBufferC_TT instance-type as common-instance-type, useable in a class-macro as: class##_TT
MK_BUF class-shortcut for struct MkBufferS *, all shortcut using the XX_YYY syntax (only for public API) …
MK_BUFR reference-shortcut for struct MkBufferS, all shortcut using the XX_YYYR syntax (only for public API) …
MkBufferCR instance-struct-reference same as struct MkBufferS, useable in a class-macro as: class##R
MkBufferCT_X(instance) cast from an instance into the specific-instance-type
MkBufferCTT_X(instance) cast from an instance into the common-instance-type
MkBufferCT_TT(typ) cast from an common-instance-type into an specific-instance-type
MkBufferCTT instance-type as common-instance-type for MkBufferC in the target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO)
MkBufferCT instance-type as specific-instance-type for MkBufferC in the target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO)

the struct(s) are defined as:

  1. The instance-type is a type-struct able to create an instance.
  2. The type-type is a type-struct not able to create an instance but used as super-class for a instance-type and the base-type
  3. The base-type is a type-struct and used to initialize the type-properties and type-methods (called slots).
    An instance provide methods and slots. A slot is a method predefined in the type like constructor. A list of all slots are defined in MkTypeS.

    example MkBufferC : MkTypeS -> MkDefTypeS -> MkObjectST -> MkBufferST

  4. The instance is a link between the instance-struct, the base-struct the instance-type and the base-type.

    example MkBufferC : MkBufferST -> MkBufferS <- MkObjectS

  5. The base-struct is used to provide the base-instance-properties
    struct MyBaseStruct {
    union {
    struct MkObjectS obj
    } super;
    // MyBaseStruct-properties
    }
    struct MyInstanceStruct {
    union {
    struct MkObjectS obj
    struct MyBaseStruct bse
    } super;
    // MyInstanceStruct-properties
    }

To use the specific-instance-type as argument to a function or as property in a struct the common-instance-type of type MkTypeS is used. To cast a specific-instance-type into a common-instance-type use:

  1. the path: type->super.typ
  2. the shortcut: MkTYP(type)->XYZ (pointer) or MkTYP_R(type).XYZ (reference)

To get the common-instance-type from the instance use:

  1. the path: instance->super.obj.type
  2. the shortcut: MkOBJ(instance)->type (pointer) or MkOBJ_R(instance).type (reference)

To get the base-type from the instance-type use:

  1. the path: instance->super.obj.type->base
  2. the shortcut: MkOBJ(instance)->type->base (pointer) or MkOBJ_R(instance).type->base (reference)

The predefined instance-type is an instance of the default-instance-type (MkDefTypeS) …

struct MkRuntimeS {
...
struct MkDefTypeS _MkBufferST;
...
}

The properties and slots of the instance-type are predefined by the base-type and may be overwritten …

The following relationship between the three different struct exists:

  1. The instance-type and the type-type have the super-class MkTypeS and the instance not.
  2. The type-type is a super-class of an instance-type.
  3. The instance-type has the 3 attributes MkTypeS::objsig, MkTypeS::objmask and MkTypeS::objsize defined, the type-type not.
  4. The instance has access to the instance-type using the cast (example MkBufferCT_X(instance))
  5. The instance-type has access to the base using MkTypeS::base and to the type using MkObjectS::type.

MANAGED OBJECT PROGRAMMING

The Programming-Language-Micro-Kernel using the manged-object technology to create a class-system with MkObjectS as the root-class.
The MkObjectS is the FIRST and REQUIRED attribute in the super-union.

  1. The instance-type is a composition of one or more super-classes and instance-attributes.
  2. All super-classes are grouped into a annonymous union called super.
  3. Only the super-class struct MkObjectS obj is required for object-management, all other super-classes are optional.
  4. The name of the super-class like obj or buf is fix and is required by tool-macros and functions.
// instance-type: MyFeatureS
struct MyStructS {
// instance super-class
union {
struct MkObjectS obj; // 'object' instance-type (required)
struct MkBufferS buf; // 'buffer' instance-type (optional,example)
} super;
// instance attribute
int myInt; …
}

A class is a link (MkObjectS::type) between:

instance-type(example: MkBufferS)
type-type(example: MkBufferSTTMkDefTypeSTTMkTypeSTT)

A class is identified by the signature (MkObjectS::signature) located at the FIRST int32 bits of the class-instance.

  • The managed-object supports one or more super-class using a union with struct MkObjectS obj as the first attribute in the union.
  • The union is required because the managed-object share the memory with the super-class.

There are two possible "cast" operations on a managed-object :

  1. A "cast" from a pointer of unknown origin (example: MK_MNG).
  2. A "cast" from an already known managed object pointer (example: MK_BUS).

In (1) the "cast" is checked using the "signature" and in (2) the "cast" is simply resolved within the "super-class".

Example: "cast" a pointer into a MkBufferS

  • "cast" from an unknown pointer: MK_BUF ret = MkBuf(ptr);
    • This "cast" is called an up-cast because you're upgrading the pointer (getting more information).
    • This "cast" checks the MkObjectS::signature to ensure that ptr is a valid object.
    • This "cast" is checked at runtime.
  • "cast" from a managed pointer: MK_BUF ret = MkBUF(ptr);
    • This "cast" is called a down-cast because you downgrading the pointer (lose some information).
    • This "cast" uses the super-union to just return a pointer that is already available.
    • This "cast" is checked at compile time.
  • To put it simply: MkBuf ≠ MkBUF

Example from kernel_mk.h A full class example from MkBufferS

struct MkBufferS {
// BEGIN-MkBufferS-super - created by 'cls_MqS.tcl -i NHI1_HOME/theKernel/libmkkernel/.libmkkernel.meta' - DO NOT change
union {
struct MkObjectS obj; // base CLASS \MkObjectS
} super;
// END-MkBufferS-super - created by 'cls_MqS.tcl -i NHI1_HOME/theKernel/libmkkernel/.libmkkernel.meta' - DO NOT change
// instance attributes
struct {
MK_NUM cursize;
enum MkTypeE type;
} var;
// instance storage
struct {
union MkBufferU first;
bool doBufferFree;
} storage;
struct ilsS {
} ils;
#define MkBufferS_ils_size 0
};
// BEGIN-MkBufferS-ClassDef - created by 'cls_MqS.tcl -i NHI1_HOME/theKernel/libmkkernel/.libmkkernel.meta' - DO NOT change
// Signature --------------------------------------------------------------
#define MkBufferC_SIGNATURE (MkObjectC_SIGNATURE ^ (1u<<10))
#define MkBufferC_MASK (((1u<<22)-1)<<10)
// Signature --------------------------------------------------------------
#define MkBufferC_X2buf(x) (x)
#define MkBufferC_X2obj(x) MkOBJ(x)
// TypeDef --------------------------------------------------------------
__parser__(ignore) typedef struct MkBufferS MkBufferCR;
__parser__(ignore) typedef const struct MkBufferS MkBufferCNR;
#define MkBufferC_T (&MK_RT_REF._MkBufferC_T)
#define MkBufferC_TT (MkTYP(MkBufferC_T))
#define MkBufferST MkBufferC_T
#define MkBufferSTT (MkTYP(MkBufferST))
#define MkBufferC_type MK_BUF
#define MkBufferCT_X(instance) ( (struct MkDefTypeS *) (MkOBJ_R(instance).type) )
#define MkBufferCTT_X(instance) (MkOBJ_R(instance).type)
#define MkBufferCT_TT(typ) ( (struct MkDefTypeS *) (typ) )
#define MkBufferC_NS MK
#define MkBufferCTT MkBufferCTT
#define MkBufferCT ( (struct MkDefTypeS *) MkBufferCTT )
// TypeCheck --------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes"
__parser__(class=MkBufferC,static,hide)
return MkSanitizeCheck(MkBufferC,mng);
}
#pragma GCC diagnostic pop
#define MkBufferC_Check(mng) MkBufCheck(mng)
// ObjectCast --------------------------------------------------------------
__parser__push__(prefix=Cast);
__parser__(class=MkBufferC,hide,static)
META_ATTRIBUTE_SANITIZE
return (MkBufCheck(mng) ? (MK_BUF)mng : NULL);
}
__parser__(ignore)
META_ATTRIBUTE_SANITIZE
return (MkBufCheck(mng) ? (MK_BUFN)mng : NULL);
}
#define MkBufRaise(_buf) if (!_MkCheckX(MkBufferC,_buf)) { \
MkErrorSetC_1E("'MkBufferC' hdl is NULL"); \
goto error ; \
}
#define MkBUF_R(x) (*(x)).super.buf
#define MkBUF(x) (&MkBUF_R(x))
// END-MkBufferS-ClassDef - created by 'cls_MqS.tcl -i NHI1_HOME/theKernel/libmkkernel/.libmkkernel.meta' - DO NOT change

MkObjectC DBG

C-API: MkObjectC_Dbg_C_API - log a debugging-message to the MkLogFileC (default: stderr) …

This functions are "helpers" to support the programmer.

[static] MkObjectC.DbgM(String message, ?int debug = 0?, ?String callfunc = null?, ?int lvl = 0?)

TOP

debug: write a static-marker to the MkLogFileC (default: stderr) … → API: javamsgque.mkkernel.MkObjectC.DbgM

obj.DbgDump(?String message = "var"?, ?String callfunc = null?)

TOP

debug: Dump a instance to stderr with LNG and MQ internal data… → API: javamsgque.mkkernel.MkObjectC.DbgDump

Attention
this is only implemented by the Target-Programming-Language

fmtobj.DbgL(String message, ?int debug = 0?, ?String callfunc = null?, ?int lvl = 0?)

TOP

debug: write a instance-marker to the MkLogFileC (default: stderr) using the fmtobj as prefix … → API: javamsgque.mkkernel.MkObjectC.DbgL

The marker is prefixed with object data from th fmtobj.

obj.DbgLogC(?String callfunc = null?)

TOP

debug: write a short-obj-summary to MkLogFileC (default: stderr) … → API: javamsgque.mkkernel.MkObjectC.DbgLogC

obj.DbgO(?String callfunc = null?)

TOP

idebug: write the object-details to MkLogFileC (default: stderr) … → API: javamsgque.mkkernel.MkObjectC.DbgO

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)

This function can be overwritten in the target programming language.

fmtobj.DbgSTACK(?int skip = 0?, ?int num = -1?, ?String callfunc = null?)

TOP

debug: write the stack-trace to MkLogFileC (default: stderr) … → API: javamsgque.mkkernel.MkObjectC.DbgSTACK

MkObjectC INTROSPECTION

C-API: MkObjectC_Introspection_C_API - Get information from the MkTypeS.

Get information about all instances created by class

The Introspection API is used to get information about the details of the instance and type implementation. Only the connection between type and instance is currently implemented.

Three methods are used to create an iteration over all avaialable instances of a type.

  • Every class has a Linked-List of all instances created starting from last to first.
  • The Introspection support always 3 Functions per class: Instance (static), Next and Prev
  • The Instance (example: [static] MkBufferC MkBufferC.Instances())
    • return the last-instance created or null if no instance was created.
  • The Next (example: MkBufferC buf.Next())
    • return the next-instance for a given-instance or null if the given-instance is the last-instance.
  • The Prev (example: MkBufferC buf.Prev())
    • return the previous-instance for a given-instance or null if the given-instance is the first-instance.

Example: a simple loop over all instances of class MkBufferC (language C++)

for (auto buf = MkBufferC::Instances(); buf != NULL; buf = buf->Next()) {
SendC(buf->ToString());
}

[static] MkObjectC MkObjectC.Instances()

TOP

get head-instance from linked-list of MkObjectS type … → API: javamsgque.mkkernel.MkObjectC.Instances

The head-instance is the last instance created.

MkObjectC obj.Next()

TOP

get next instance from linked-list of MkObjectS type → API: javamsgque.mkkernel.MkObjectC.Next

MkObjectC obj.Prev()

TOP

get previous instance from linked-list of MkObjectS type → API: javamsgque.mkkernel.MkObjectC.Prev

MkObjectC LOG

C-API: MkObjectC_Log_C_API - log information to MkLogFileC (default: stderr) …

The logging-target is set direct by RuntimeSetLogfile or using the class MkLogFileC.

The target is stored at the MkRuntimeC using a FILE-stream and can be set individually for each thread. The default is stderr.

possible values are:

value decription OS man-page
stdout the standart output stdio(3)
stderr the standart error output stdio(3)
fileName an arbitary fileName fopen(3)

Many logging functions have common parameters:

Parameters
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)

fmtobj.LogC(String message, ?int debug = 0?, ?String callfunc = null?)

TOP

write a logging-message to MkLogFileC (default: stderr) using the internal format … → API: javamsgque.mkkernel.MkObjectC.LogC

The logging is only done if 'MqDebug >= level' and 'MqIsSilent == false' using the following format:

C> (NAME:PID:THREADID) [YYYY-MM-DD:HH-MM-SS] [String|Binary-DEBUGLEVEL-CONTEXTID-REFCOUNT-CONTEXTPTR-prefix]: message

The message is build with snprintf and finally send with fputsn without newline '\n' character at the end. To add the newline or an other special-caracter use the '\xxx' syntax.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)
[in]messagestring to log

fmtobj.LogHEX(?String callfunc = null?, byte[] data)

TOP

log binaray data as HEX into the MkLogFileC (default: stderr) … → API: javamsgque.mkkernel.MkObjectC.LogHEX

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]datathe binary data to log

obj.Log(?MkObjectC fmtobj = null?, ?int debug = 0?, ?String callfunc = null?, ?int lvl = 0?)

TOP

Log-Slot - log the entire object to the MkLogFileC (default: stderr) target … → API: javamsgque.mkkernel.MkObjectC.Log

Todo:

log_doku

slot_doku

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]lvla user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0)
See also
BufferLog, BufferListLog, BufferStreamLog, ?MkLogFileLog?, ErrorLog, RuntimeDebug, ObjectLogSimple

obj.LogDetail(?MkObjectC fmtobj = null?, ?int debug = 0?, ?String callfunc = null?, ?int lvl = 0?)

TOP

log the MkObjectS verbose into the MkLogFileC (default: stderr) … → API: javamsgque.mkkernel.MkObjectC.LogDetail

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]lvla user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0)
See also
MkObjectC obj.Log(?MkObjectC fmtobj = null?, ?int debug = 0?, ?String callfunc = null?, ?int lvl = 0?)

obj.LogSimple(?MkObjectC fmtobj = null?, ?int debug = 0?, ?String callfunc = null?, ?int lvl = 0?)

TOP

log the MkObjectS into the MkLogFileC (default: stderr) … → API: javamsgque.mkkernel.MkObjectC.LogSimple

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]lvla user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0)
See also
MkObjectC

MkObjectC MISC

C-API: MkObjectC_Misc_C_API - Various functions related to the MkObjectC

[static] MkObjectC MkObjectC.FromHandle(long exporthdl)

TOP

Import-Slot - returns a obj from a former exported handle → API: javamsgque.mkkernel.MkObjectC.FromHandle

Parameters
[in]exporthdlhandle former exported with ObjectToHandle
Returns
the required handle or NULL if handle is invalid

MkErrorC obj.ErrorCatch(?Throwable exception = null?, ?String callfunc = null?)

TOP

convert a programming-language-error into an javamkkernel error … → API: javamsgque.mkkernel.MkObjectC.ErrorCatch

This function is a placeholder and have to be overloaded by the Target-Programming-Language. The goal is to handel an error-catch condition and convert an programming-language-error into an javamkkernel-error.

This is the same as (example form c++):

mngx->ErrorDEFAULT()->Catch(exception)

Example from server.java catch-send and reset an error

	  cl[id].SendSTART();
	  try {
	    ProxyItem(cl[id]);
	    cl[id].SendEND_AND_WAIT("ECOI", 5);
	  } catch (Throwable ex) {
	    MkErrorC err = ErrorCatch(ex);
	    SendI(err.GetNum());
	    SendC(err.GetText());
	    err.Reset();
	  }
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
[in]exceptionthe exception object from Java, if null the global exception object is used
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
Returns
the ErrorDEFAULT initialized with exception value
See also
err.Raise() err.Reset(?String callfunc = null?, ?int callline = -1?, ?boolean force = false?)

MkErrorC obj.ToError()

TOP

Error-Slot - return an error-object pre initialized with obj data. → API: javamsgque.mkkernel.MkObjectC.ToError

This slot is the same as ErrorDEFAULT with fmtobj set to this

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
Returns
the error-object
Attention
The memory of the out-value belongs to the called JavaMkKernel function and therefore never becomes null. For details on the out-value, see: MkKernel_Storage_C_API.

long obj.ToHandle()

TOP

Export-Slot - returns a reference to the obj useable for external storage → API: javamsgque.mkkernel.MkObjectC.ToHandle

A handle is a reference for an instance. A handle can be converted back into an instance using the ?Class?FromHandle syntax like [static] MkBufferListC MkBufferListC.FromHandle(long exporthdl)

Parameters
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
Returns
the required handle

String obj.ToName()

TOP

Info-Slot - returns brief information about the obj as a string → API: javamsgque.mkkernel.MkObjectC.ToName

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
Returns
the identification of the object as string
Attention
The memory of the out-value belongs to the called JavaMkKernel function and therefore never becomes null. For details on the out-value, see: MkKernel_Storage_C_API.

String obj.ToNameOfClass()

TOP

Class-Slot - returns the JV-Class-Name of the obj as string → API: javamsgque.mkkernel.MkObjectC.ToNameOfClass

The Programming-Language-Micro-Kernel connect the JV language with the libmqmsgque runtime. Every class-object in JV has an conterpart as libmqmsgque type-object in the Programming-Language-Micro-Kernel.

ObjectToNameOfType returns the name of the libmqmsgque type
ObjectToNameOfClass returns the name of the JV class

String obj.ToNameOfType()

TOP

Type-Slot - returns the LibMkKernel-Type-Name of the obj as a string → API: javamsgque.mkkernel.MkObjectC.ToNameOfType

The Programming-Language-Micro-Kernel connect the JV language with the LibMsgque runtime. Every class-object in JV has an conterpart as LibMsgque type-object in the Programming-Language-Micro-Kernel.

ObjectToNameOfType returns the name of the libmsgque type
ObjectToNameOfClass returns the name of the JV class
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
Returns
the name of the object-type as a string

String obj.ToString()

TOP

String-Slot - returns the string representation of the obj … → API: javamsgque.mkkernel.MkObjectC.ToString

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
Returns
the required string
Attention
~ The memory of the out-value belongs to the called JavaMkKernel function and therefore never becomes null. For details on the out-value, see: MkKernel_Storage_C_API.
~ On error an empty string is returned.

MkObjectC TOR

C-API: MkObjectC_TOR_C_API - Create and Destroy a managed-object.

[destructor] obj.Delete()

TOP

Delete-Slot - delete an instance. → API: javamsgque.mkkernel.MkObjectC.Delete

There are two different ways to delete an instance:

ObjectDisposeto free the internal data but keep the outher shell alive - this is called a SOFT-DELETE
ObjectDelete to delete the outher shell including the internal data - this is called a HARD-DELETE
Attention
  1. The internal memory will be freed and the object-pointer will be set to NULL. If the object-pointer is already NULL nothing will be done.
  2. For a programming language without HARD-Delete support, the "Delete" method is assigned to a SOFT-Delete.
  3. For a programming language without garbage collection, a SOFT-delete without a HARD-delete causes a small memory loss (C++: ~32 bytes).
  4. After a SOFT-delete, the outher shell is still alive, but cannot be used. Any access to this shell generates an HDL-null-exception, but this exception can be caught. This is important for C++ as it prevents a core dump.
  5. On HARD-delete read more at SelfDeleteForce

[destructor] obj.Dispose()

TOP

Dispose-Slot - untie the connection between the Native-JV-Instance and the LibMsgque-Instance. → API: javamsgque.mkkernel.MkObjectC.Dispose

There are two different ways to delete an instance:

ObjectDispose to free the internal data but keep the outher shell alive - this is called a SOFT-DELETE
ObjectDelete to delete the outher shell including the internal data - this is called a HARD-DELETE
Attention
1. For a programming language without HARD-Delete support, the "Delete" method is assigned to a SOFT-Delete.
2. For a programming language without garbage collection, a SOFT-delete without a HARD-delete causes a small memory loss (C++: ~32 bytes).
3. After a SOFT-delete, the outher shell is still active, but cannot be used. Any access to this shell generates an HDL-null-exception, but this exception can be caught. This is important for C++ as it prevents a core dump.

MkBufferC

MkBufferC ACCESS

AppendCappend a single string to a MkBufferC object …
Popdelete str from the MkBufferC
Push

add str to the MkBufferC

MkBufferC GET

GetTT

get a val_out from a MkBufferC

MkBufferC INFO

GetType1return the type from a MkBufferC as single character value …
GetType2return the MkTypeE from a MkBufferC
GetType3return the type from a MkBufferC as single character string …
IsLocalCheck if the MkBufferC is local (temporary), not local mean global
Loglog the MkBufferC
LogS

log the short MkBufferC object data to the MkLogFileC (default: stderr) …

MkBufferC INTROSPECTION

Instancesget head-instance from linked-list of MkBufferS type …
Nextget next instance from linked-list of MkBufferS type
Prev

get previous instance from linked-list of MkBufferS type

MkBufferC MISC

CastTochange the type of an MkBufferC to type
Cmpcompare TWO MkBufferC objects like strcmp do it for strings …
Copycopy the MkBufferC from srce to dest
Resetreset a MkBufferC to the length zero …
ResetFullreset a MkBufferC to the length zero and free allocated storage…
SizeAddadd size storage to the buf
SizeNewalloc min size storage to the buf
Tempcreate a temporary copy of the MkBufferC buf …
ToString

get the string representation of the buf

MkBufferC SET

SetTT

Set the MkBufferC to the val

MkBufferC TOR

CreateConstructor - create a new MkBufferC with minimum size of internal storage …
Create1024call the BufferCreate with default type MkBuffer1024S (1024 byte) …
Create256call the BufferCreate with default type MkBuffer256S (256 byte) …
Create64call the BufferCreate with default type MkBuffer64S (64 byte) …
CreateTLSsame as BufferCreate but require no cleanup
CreateTTConstructor - create a new MkBufferC with an PRIMITIVE TYPE
FromHandleImport-Slot - returns a obj from a former exported handle
DeleteDestructor - delete a MkBufferC instance …
DupDup-Constructor - create a new MkBufferC instance as copy from an existing MkBufferC instance
Merge

Merge-Constructor - create a new MkBufferC as a merge from an existing object …

MkBufferC DETAIL

C-API: MkBufferC_C_API - The MkBufferC object known as buf or buffer is used to create and manage dynamic, generic, mixed typed data. …

The MkBufferC is used to store PRIMITIVE TYPE data. If javamkkernel is working on data… javamkkernel is working on an MkBufferC object or on a list of MkBufferC objects called MkBufferListC.

MkBufferC CLASS

The ABSTRACT-CLASS used to store a native-type-data-item defined by PRIMITIVE TYPE

C-Kernel-Details

The ABSTRACT-CLASS MkBufferS is used to store MkTypeE data in an MkBufferS::storage

A new MkBufferS is always preallocated with the predefined ILS-storage (MkBufferS::ils_data), but can switch to a MALLOC-storage if the storage requirements of the user exceed the predefined MkBufferS::ilsS::size.

‍A MkBufferS never run out of storage.

The basic goal of the ILS-storage technology is to minimize the usage of MALLOC, this mean that the MkBufferS::ilsS::size should be large enought to be sufficient for the user needs.

The following conditions must always be met for the ILS memory:

The ABSTRACT-CLASS MkBufferS is missing the ILS-storage, the FINAL-CLASSES are:

MkBuffer64C, MkBuffer256C and MkBuffer1024C

See also
MkBufferListC, MkBufferStreamC

MkBufferC CTOR / DTOR

command synonmym
[constructor] MkBufferC.Create(?int size = 0?) javamsgque.mkkernel.MkBufferC(wide size = 0)
[destructor] buf.Delete() buf.Dispose()

Example from server.java read a buffer-object and convert single-char-type-identifer to string.

class BUF2 implements ICallback {
  public void Callback(MqContextC ctx) {
    ctx.SendSTART();

    for (int i=0; i<3; i++) {
      MkBufferC buf = ctx.ReadU();
      ctx.SendC(Character.toString(buf.GetType1()));
      ctx.SendU(buf);
    }

    ctx.SendRETURN();
  }
}
See also
BufferGetType1 BufferGetType2 BufferGetType3

MkBufferC ACCESS

C-API: MkBufferC_Access_C_API - various functions to access buffer-data

MkBufferC buf.AppendC(String val)

TOP

append a single string to a MkBufferC object … → API: javamsgque.mkkernel.MkBufferC.AppendC

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
[in]valthe text to append to buf
Returns
the MkBufferC object with the new value

Example from server.java read and update a MkBufferC

	  // ReadU - Example, read a buffer-object and append a string
	  buf = ReadU();
	  buf.AppendC("- a really log text to overwrite the already allocated space");
	  SendU(buf);
	  SendI(ReadI()+1);

int buf.Pop(String val)

TOP

delete str from the MkBufferC … → API: javamsgque.mkkernel.MkBufferC.Pop

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
valthe text (string) to remove from buf
Returns
the size of the string removed from the MkBuffer64S object
Attention
MkBufferC have to be of type MK_STRT

int buf.Push(String val)

TOP

add str to the MkBufferC … → API: javamsgque.mkkernel.MkBufferC.Push

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
valthe text (string) to append to buf
Returns
the size of the string appended to the MkBuffer64S object
Attention
MkBufferC have to be of type MK_STRT

MkBufferC GET

C-API: MkBufferC_Get_C_API - various functions to get buffer-data

buf.GetTT()

The BufferGetTT provide a single function for every PRIMITIVE TYPE

returncommand

C-API :

byte[] buf.GetB()MkBufferGetB_RT
String buf.GetC()MkBufferGetC_RT
double buf.GetD()MkBufferGetD_RT
float buf.GetF()MkBufferGetF_RT
int buf.GetI()MkBufferGetI_RT
MkBufferListC buf.GetL(?MkBufferListC val_inout = null?)MkBufferGetL_RT
boolean buf.GetO()MkBufferGetO_RT
short buf.GetS()MkBufferGetS_RT
MkBufferC buf.GetU()MkBufferGetU_RT
long buf.GetW()MkBufferGetW_RT
byte buf.GetY()

MkBufferGetY_RT

get a val_out from a MkBufferC

The MkBufferGetTT style of functions always return a val_out or a MkErrorC.

The val_out can be a PRIMITIVE TYPE, a class-type or a pointer-type (binary, string etc).

Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) - (nonnull)
[in]bufthe MkBufferS instance to work on - (nonnull)
[out]val_outthe value to return - (nonnull)

MkBufferC INFO

C-API: MkBufferC_Info_C_API - various functions to get information out of buffer-data

char buf.GetType1()

TOP

return the type from a MkBufferC as single character value … → API: javamsgque.mkkernel.MkBufferC.GetType1

MK_BUFN const buf
)
{
switch (buf->var.type) {
case MK_STRT: return 'C';
case MK_INTT: return 'I';
case MK_DBLT: return 'D';
case MK_WIDT: return 'W';
case MK_BINT: return 'B';
case MK_BYTT: return 'Y';
case MK_BOLT: return 'O';
case MK_SRTT: return 'S';
case MK_FLTT: return 'F';
case MK_LSTT: return 'L';
}
return '*';
}
MK_EXTERN MK_STRB MkBufferGetType1_RT(MK_RT const mkrt, MK_BUFN const buf) MK_RT_ATTR_HDL
return the type from a MkBufferC as single character value …
char MK_STRB
string type data-type
Definition kernel_mk.h:2703
#define MK_RT_ATTR_HDL_CHECK(x)
Definition kernel_mk.h:2421
#define MK_RT_ATTR_RUNTIME_CHECK_XN(x)
Definition kernel_mk.h:2424
#define MK_RT_ARGS
Definition kernel_mk.h:2365

MkTypeE buf.GetType2()

TOP

return the MkTypeE from a MkBufferC … → API: javamsgque.mkkernel.MkBufferC.GetType2

enum MkTypeE
MK_BUFN const buf
) {
return buf->var.type;
}
MK_EXTERN enum MkTypeE MkBufferGetType2_RT(MK_RT const mkrt, MK_BUFN const buf) MK_RT_ATTR_HDL
return the MkTypeE from a MkBufferC …

String buf.GetType3()

TOP

return the type from a MkBufferC as single character string … → API: javamsgque.mkkernel.MkBufferC.GetType3

MK_BUFN const buf
) {
switch (buf->var.type) {
case MK_STRT: return "C";
case MK_INTT: return "I";
case MK_DBLT: return "D";
case MK_WIDT: return "W";
case MK_BINT: return "B";
case MK_BYTT: return "Y";
case MK_BOLT: return "O";
case MK_SRTT: return "S";
case MK_FLTT: return "F";
case MK_LSTT: return "L";
}
return "*";
}
MK_EXTERN MK_STRN MkBufferGetType3_RT(MK_RT const mkrt, MK_BUFN const buf) MK_RT_ATTR_HDL
return the type from a MkBufferC as single character string …
const MK_STRB * MK_STRN
constant string pointer data-type
Definition kernel_mk.h:2745

boolean buf.IsLocal()

TOP

Check if the MkBufferC is local (temporary), not local mean global … → API: javamsgque.mkkernel.MkBufferC.IsLocal

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
Returns
a boolean value… yes or no

buf.Log(?MkObjectC fmtobj = null?, ?int debug = 0?, ?String callfunc = null?, ?int lvl = 0?)

TOP

log the MkBufferC … → API: javamsgque.mkkernel.MkBufferC.Log

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]lvla user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0)
See also
MkBufferC

buf.LogS(?String varname = "buf"?, ?MkObjectC fmtobj = null?, ?String callfunc = null?)

TOP

log the short MkBufferC object data to the MkLogFileC (default: stderr) … → API: javamsgque.mkkernel.MkBufferC.LogS

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
[in]varnameThe name of the argument to report
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)

MkBufferC INTROSPECTION

C-API: MkBufferC_Introspection_C_API - Get information from the MkTypeS.

Get information about all instances created by class

Get information about all instances created by class

The Introspection API is used to get information about the details of the instance and type implementation. Only the connection between type and instance is currently implemented.

Three methods are used to create an iteration over all avaialable instances of a type.

  • Every class has a Linked-List of all instances created starting from last to first.
  • The Introspection support always 3 Functions per class: Instance (static), Next and Prev
  • The Instance (example: [static] MkBufferC MkBufferC.Instances())
    • return the last-instance created or null if no instance was created.
  • The Next (example: MkBufferC buf.Next())
    • return the next-instance for a given-instance or null if the given-instance is the last-instance.
  • The Prev (example: MkBufferC buf.Prev())
    • return the previous-instance for a given-instance or null if the given-instance is the first-instance.

Example: a simple loop over all instances of class MkBufferC (language C++)

for (auto buf = MkBufferC::Instances(); buf != NULL; buf = buf->Next()) {
SendC(buf->ToString());
}

[static] MkBufferC MkBufferC.Instances()

TOP

get head-instance from linked-list of MkBufferS type … → API: javamsgque.mkkernel.MkBufferC.Instances

The head-instance is the last instance created.

MkBufferC buf.Next()

TOP

get next instance from linked-list of MkBufferS type → API: javamsgque.mkkernel.MkBufferC.Next

MkBufferC buf.Prev()

TOP

get previous instance from linked-list of MkBufferS type → API: javamsgque.mkkernel.MkBufferC.Prev

MkBufferC MISC

C-API: MkBufferC_Misc_C_API - various functions to work on buffer-data

buf.CastTo(MkTypeE typ)

TOP

change the type of an MkBufferC to type … → API: javamsgque.mkkernel.MkBufferC.CastTo

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
[in]typcast buf to typ
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR

int buf1.Cmp(MkBufferC buf2)

TOP

compare TWO MkBufferC objects like strcmp do it for strings … → API: javamsgque.mkkernel.MkBufferC.Cmp

-# if both types are equal than the native types are compared

  1. if both types are non-equal than the string representation of the types are compared
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]buf1the FIRST MkBufferC object to compare
[in]buf2the SECOND MkBufferC object to compare
Returns
Returns < 0 if buf1 is less than buf2; > 0 if buf1 is greater than buf2, and 0 if they are equal.

MkBufferC buf.Copy(MkBufferC srce)

TOP

copy the MkBufferC from srce to dest … → API: javamsgque.mkkernel.MkBufferC.Copy

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
srcesource of the copy
Returns
the dest object

buf.Reset()

TOP

reset a MkBufferC to the length zero … → API: javamsgque.mkkernel.MkBufferC.Reset

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
See also
buf.ResetFull()

buf.ResetFull()

TOP

reset a MkBufferC to the length zero and free allocated storage… → API: javamsgque.mkkernel.MkBufferC.ResetFull

In addition to buf.Reset() the allocated storage is freed and reset to ILS

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
See also
buf.Reset()

MkBufferC buf.SizeAdd(int size)

TOP

add size storage to the buf … → API: javamsgque.mkkernel.MkBufferC.SizeAdd

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
[in]sizeThe initial size of the instance-local-storage. The MkBufferC has dynamic-memory-management, the size value is just a hint to provide enought memory for future tasks. The real size created is the maximum of type-ILS-size and size . (default: 0 = use the type-ILS-size)
Returns
the input buf

MkBufferC buf.SizeNew(int size)

TOP

alloc min size storage to the buf … → API: javamsgque.mkkernel.MkBufferC.SizeNew

Returns
the input buf
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
[in]sizeThe initial size of the instance-local-storage. The MkBufferC has dynamic-memory-management, the size value is just a hint to provide enought memory for future tasks. The real size created is the maximum of type-ILS-size and size . (default: 0 = use the type-ILS-size)

MkBufferC buf.Temp()

TOP

create a temporary copy of the MkBufferC buf … → API: javamsgque.mkkernel.MkBufferC.Temp

This function always return the same global memory from the per-thread-runtime-storage initialized with buf. This storage must not be freed and should only be used for temporary-short-time usage. In theory every function-call in the same thread could overwrite this memory.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
buf- the source of the copy
Returns
the temporary buffer-object
Attention
The memory of the out-value belongs to the called JavaMkKernel function and therefore never becomes null. For details on the out-value, see: MkKernel_Storage_C_API.

String buf.ToString()

TOP

get the string representation of the buf … → API: javamsgque.mkkernel.MkBufferC.ToString

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
Returns
the required string
Attention
~ The returned string is owned by self… do not free.
~ On error an empty string is returned.

MkBufferC SET

C-API: MkBufferC_Set_C_API - various functions to set buffer-data

buf.SetTT(byte val)

The BufferSetTT provide a single function for every PRIMITIVE TYPE

returncommand

C-API :

MkBufferC buf.SetB(byte[] val)MkBufferSetB_RT
MkBufferC buf.SetC(String val)MkBufferSetC_RT
MkBufferC buf.SetD(double val)MkBufferSetD_RT
MkBufferC buf.SetF(float val)MkBufferSetF_RT
MkBufferC buf.SetI(int val)MkBufferSetI_RT
MkBufferC buf.SetO(boolean val)MkBufferSetO_RT
MkBufferC buf.SetS(short val)MkBufferSetS_RT
MkBufferC buf.SetU(MkBufferC val)MkBufferSetU_RT
MkBufferC buf.SetW(long val)MkBufferSetW_RT
MkBufferC buf.SetY(byte val)

MkBufferSetY_RT

Set the MkBufferC to the val

The old value will be removed and the memory will be reset.

Returns
the MkBufferS object
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
[in]valthe value to set the buf to

MkBufferC TOR

C-API: MkBufferC_TOR_C_API - various functions to create, initialize and destroy a MkBufferC

[constructor] MkBufferC.Create(?int size = 0?)

TOP

Constructor - create a new MkBufferC with minimum size of internal storage … → API: javamsgque.mkkernel.MkBufferC.Create

The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferDelete is always possible, but the instance can no longer be used afterwards.

There is a MkBufferCreateTT function for every PRIMITIVE TYPE.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]typeA type defined as MkTypeS with a TT postfix (default: MkBuffer64S, possible: MkBuffer64S, MkBuffer256S and MkBuffer1024S)
[in]sizeThe initial size of the instance-local-storage. The MkBufferC has dynamic-memory-management, the size value is just a hint to provide enought memory for future tasks. The real size created is the maximum of type-ILS-size and size . (default: 0 = use the type-ILS-size)
Returns
The newly created MkBufferC instance, the instance is owned by the caller
See also
BufferDelete BufferDup MqReadU

[constructor] MkBufferC.Create1024(?int size = 0?)

TOP

call the BufferCreate with default type MkBuffer1024S (1024 byte) … → API: javamsgque.mkkernel.MkBufferC.Create1024

[constructor] MkBufferC.Create256(?int size = 0?)

TOP

call the BufferCreate with default type MkBuffer256S (256 byte) … → API: javamsgque.mkkernel.MkBufferC.Create256

[constructor] MkBufferC.Create64(?int size = 0?)

TOP

call the BufferCreate with default type MkBuffer64S (64 byte) … → API: javamsgque.mkkernel.MkBufferC.Create64

[constructor] MkBufferC.CreateTLS(int tlsid)

TOP

same as BufferCreate but require no cleanup → API: javamsgque.mkkernel.MkBufferC.CreateTLS

A TLS-instance only exists ONCE per thread and per TLS-function in memory. The memory will be reused and must not be freed.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]tlsidAn per-thread unique name (integer > 0) to identify the reuse-able instance-storage. The tlsid have to be between: 0 <= tlsid < 32
Returns
the new MkBufferC instance, the instance belongs to the TLS-function and does not need to be deleted.
Note
This function is intended as a replacement for MkBufferCreateTLS_T for non-C programming languages.
Attention
for usage of the TLS-storage read more at StorageCreateTLS

[static] MkBufferC MkBufferC.FromHandle(long exporthdl)

TOP

Import-Slot - returns a obj from a former exported handle → API: javamsgque.mkkernel.MkBufferC.FromHandle

Parameters
[in]exporthdlhandle former exported with ObjectToHandle
Returns
the required handle or NULL if handle is invalid

[destructor] buf.Delete()

TOP

Destructor - delete a MkBufferC instance … → API: MkBufferDelete_RT

There are two different ways to delete an instance:

ObjectDisposeto free the internal data but keep the outher shell alive - this is called a SOFT-DELETE
ObjectDelete to delete the outher shell including the internal data - this is called a HARD-DELETE
Attention
  1. The internal memory will be freed and the object-pointer will be set to NULL. If the object-pointer is already NULL nothing will be done.
  2. For a programming language without HARD-Delete support, the "Delete" method is assigned to a SOFT-Delete.
  3. For a programming language without garbage collection, a SOFT-delete without a HARD-delete causes a small memory loss (C++: ~32 bytes).
  4. After a SOFT-delete, the outher shell is still alive, but cannot be used. Any access to this shell generates an HDL-null-exception, but this exception can be caught. This is important for C++ as it prevents a core dump.
  5. On HARD-delete read more at SelfDeleteForce
See also
BufferCreate BufferDup MqReadU

[constructor] buf.Dup()

TOP

Dup-Constructor - create a new MkBufferC instance as copy from an existing MkBufferC instance → API: javamsgque.mkkernel.MkBufferC.Dup

The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferDelete is always possible, but the instance can no longer be used afterwards.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
Returns
The newly created MkBufferC instance, the instance is owned by the caller
See also
ObjDup BufferDelete

[constructor] buf.Merge()

TOP

Merge-Constructor - create a new MkBufferC as a merge from an existing object … → API: javamsgque.mkkernel.MkBufferC.Merge

The Merge-Constructor create a new instance and merge all internal data from the src into the new instance. After the Merge-Constructor the BufferResetFull is called for the merge-source bus.

One usage of the Merge-Constructor is to get a lightweight-copy of a Thread-Local-Storage object for external usage.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
Returns
The new instance or NULL on error or if no Merge-Constructor is available
Attention
The new instance have to be deleted with BufferDelete
See also
BufferDup BufferResetFull BufferDelete

[constructor] MkBufferC.CreateTT(byte val)

The BufferCreateTT provide a single function for every PRIMITIVE TYPE

returncommand

C-API :

[constructor] MkBufferC.CreateB(byte[] val)MkBufferCreateB_RT
[constructor] MkBufferC.CreateC(String val)MkBufferCreateC_RT
[constructor] MkBufferC.CreateD(double val)MkBufferCreateD_RT
[constructor] MkBufferC.CreateF(float val)MkBufferCreateF_RT
[constructor] MkBufferC.CreateI(int val)MkBufferCreateI_RT
[constructor] MkBufferC.CreateO(boolean val)MkBufferCreateO_RT
[constructor] MkBufferC.CreateS(short val)MkBufferCreateS_RT
[constructor] MkBufferC.CreateU(MkBufferC val)MkBufferCreateU_RT
[constructor] MkBufferC.CreateW(long val)MkBufferCreateW_RT
[constructor] MkBufferC.CreateY(byte val)

MkBufferCreateY_RT

Constructor - create a new MkBufferC with an PRIMITIVE TYPE

The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferDelete is always possible, but the instance can no longer be used afterwards.

Returns
The newly created MkBufferC instance, the instance is owned by the caller
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]valthe PRIMITIVE TYPE object as data-source

MkBufferStreamC

MkBufferStreamC INTROSPECTION

Instancesget head-instance from linked-list of MkBufferStreamS type …
Nextget next instance from linked-list of MkBufferStreamS type
Prev

get previous instance from linked-list of MkBufferStreamS type

MkBufferStreamC MISC

Copycopy the MkBufferStreamC from src to bus
Loglog the MkBufferStreamC
PosToStartset the current-access-position to the start of MkBufferStreamC
Resetreset a MkBufferStreamC to the length zero …
ResetFull

reset a MkBufferStreamC to the length zero and free allocated storage…

MkBufferStreamC READ

ReadALLget a temporary MkBufferListC from all data in the MkBufferStreamC
ReadGetNextTypeget the type (MkTypeE) of the next Item in the MkBufferStreamC or "0" if not available
ReadGetNumItemsget the number of items left in the MkBufferStreamC
ReadItemExistscheck if an item exists in the read-data-package
ReadLONGread the long native object from the MkBufferStreamC
ReadL_ENDEND read a list-item-type from the MkBufferStreamC
ReadL_STARTSTART read a list-item-type from the MkBufferStreamC
ReadUndoundo the last MkBufferStreamC READ function call …
ReadTT

read a val_out from the MkBufferStreamC

MkBufferStreamC TOR

Createcreate and initialize an MkBufferStreamC instance …
Create1024call the BufferStreamCreate with default type MkBufferStream1024S (1024 byte) …
Create16384call the BufferStreamCreate with default type MkBufferStream16384S (16384 byte) …
Create256call the BufferStreamCreate with default type MkBufferStream256S (256 byte) …
Create64call the BufferStreamCreate with default type MkBufferStream64S (64 byte) …
CreateTLSsame as BufferStreamCreate but require no cleanup …
FromHandleImport-Slot - returns a obj from a former exported handle
DeleteDestructor - delete a MkBufferStreamC instance …
DupDup-Constructor - create a new MkBufferStreamC instance as copy from an existing MkBufferStreamC instance …
Merge

Merge-Constructor - create a new MkBufferStreamC as a merge from an existing object …

MkBufferStreamC WRITE

WriteLONGwrite the long native object into the MkBufferStreamC
WriteL_ENDEND write a list-item-type into the MkBufferStreamC
WriteL_FLATwrite a MkBufferListC FLAT into the MkBufferStreamC
WriteL_STARTSTART write a list-item-type into the MkBufferStreamC
WriteTT

write a PRIMITIVE TYPE into the MkBufferStreamC

MkBufferStreamC DETAIL

C-API: MkBufferStreamC_C_API - The MkBufferStreamC object known as bus or stream is a subclass of MkBufferC used for package-based-io

The MkBufferStreamC is required to send data via a socket (pipe,tcp,uds,...). The data is organized as a continuous binary-array. Each item is preceded by type and, if applicable, size information.

‍See also: MkBufferC, MkBufferListC

C-Kernel-Details

The ABSTRACT-CLASS MkBufferStreamS has the private-parent-class MkBufferS and is used to store typed-data in a continuous binary-array at MkBufferS::storage.

private-parent-class mean:
MkBufferStreamS use the features of MkBufferS but does not expose the API

In addition to the binary-array the MkBufferStreamS also include features like:

  1. the encoding: MkBufferStreamS::endian_is_wrong
  2. the total number of items: MkBufferStreamS::numItems
  3. current position pointer: MkBufferStreamS::cur
  4. support for recursion: embedding a MkBufferStreamS into a MkBufferStreamS

The MkBufferStreamS inherits the following features from MkBufferS:

  1. the storage: MkBufferS::storage
  2. the type: MkBufferS::type
  3. the ILS: MkBufferS::ils

The ABSTRACT-CLASS MkBufferStreamS is missing the ILS-storage, the FINAL-CLASSES are:

MkBufferStream16384S, MkBufferStream256S, MkBufferStream64S and MkBufferStream1024S

See also
MkBufferC, MkBufferListC

MkBufferStreamC INTROSPECTION

C-API: MkBufferStreamC_Introspection_C_API - Get information from the MkTypeS.

Get information about all instances created by class

Get information about all instances created by class

The Introspection API is used to get information about the details of the instance and type implementation. Only the connection between type and instance is currently implemented.

Three methods are used to create an iteration over all avaialable instances of a type.

  • Every class has a Linked-List of all instances created starting from last to first.
  • The Introspection support always 3 Functions per class: Instance (static), Next and Prev
  • The Instance (example: [static] MkBufferC MkBufferC.Instances())
    • return the last-instance created or null if no instance was created.
  • The Next (example: MkBufferC buf.Next())
    • return the next-instance for a given-instance or null if the given-instance is the last-instance.
  • The Prev (example: MkBufferC buf.Prev())
    • return the previous-instance for a given-instance or null if the given-instance is the first-instance.

Example: a simple loop over all instances of class MkBufferC (language C++)

for (auto buf = MkBufferC::Instances(); buf != NULL; buf = buf->Next()) {
SendC(buf->ToString());
}

[static] MkBufferStreamC MkBufferStreamC.Instances()

TOP

get head-instance from linked-list of MkBufferStreamS type … → API: javamsgque.mkkernel.MkBufferStreamC.Instances

The head-instance is the last instance created.

MkBufferStreamC bus.Next()

TOP

get next instance from linked-list of MkBufferStreamS type → API: javamsgque.mkkernel.MkBufferStreamC.Next

MkBufferStreamC bus.Prev()

TOP

get previous instance from linked-list of MkBufferStreamS type → API: javamsgque.mkkernel.MkBufferStreamC.Prev

MkBufferStreamC MISC

C-API: MkBufferStreamC_Misc_C_API - various functions to create and destroy a MkBufferStreamC

MkBufferStreamC bus.Copy(MkBufferStreamC src)

TOP

copy the MkBufferStreamC from src to bus … → API: javamsgque.mkkernel.MkBufferStreamC.Copy

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
srcsource of the copy
Returns
the bus instance

bus.Log(?MkObjectC fmtobj = null?, ?int debug = 0?, ?String callfunc = null?, ?int lvl = 0?)

TOP

log the MkBufferStreamC … → API: javamsgque.mkkernel.MkBufferStreamC.Log

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]lvla user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0)

bus.PosToStart()

TOP

set the current-access-position to the start of MkBufferStreamC … → API: javamsgque.mkkernel.MkBufferStreamC.PosToStart

bus.Reset()

TOP

reset a MkBufferStreamC to the length zero … → API: javamsgque.mkkernel.MkBufferStreamC.Reset

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
See also
bus.ResetFull()

bus.ResetFull()

TOP

reset a MkBufferStreamC to the length zero and free allocated storage… → API: javamsgque.mkkernel.MkBufferStreamC.ResetFull

In addition to bus.Reset() the allocated storage is freed and reset to ILS. This is usefull if the internal storage was filled once with a huge amount of data.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
See also
bus.Reset()

MkBufferStreamC READ

C-API: MkBufferStreamC_Read_C_API - various functions to 'read' data from a MkBufferStreamC

Read is done at the position of MkBufferStreamS::storage->cur. After read the cur is incemented with read-sizeof characters.

MkBufferListC bus.ReadALL(?MkBufferListC val_inout = null?)

TOP

get a temporary MkBufferListC from all data in the MkBufferStreamC … → API: javamsgque.mkkernel.MkBufferStreamC.ReadALL

If the val_inout is NULL than a temporary MkBufferListC is returned. If the val_inout is not NULL than the memory of the val_inout is reused.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
[in,out]val_inoutthe MkBufferListC - the storage of the input is reused
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
See also
BufferStreamReadL
Attention
The memory of the out-value belongs to the called JavaMkKernel function and therefore never becomes null. For details on the out-value, see: MkKernel_Storage_C_API.

MkTypeE bus.ReadGetNextType()

TOP

get the type (MkTypeE) of the next Item in the MkBufferStreamC or "0" if not available → API: javamsgque.mkkernel.MkBufferStreamC.ReadGetNextType

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
Returns
the type

int bus.ReadGetNumItems()

TOP

get the number of items left in the MkBufferStreamC … → API: javamsgque.mkkernel.MkBufferStreamC.ReadGetNumItems

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
Returns
the number of items as integer

boolean bus.ReadItemExists()

TOP

check if an item exists in the read-data-package … → API: javamsgque.mkkernel.MkBufferStreamC.ReadItemExists

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
Returns
boolean, true or false

long bus.ReadLONG()

TOP

read the long native object from the MkBufferStreamC … → API: javamsgque.mkkernel.MkBufferStreamC.ReadLONG

on 64bit use a BufferStreamReadI and on 32bit use a BufferStreamReadW

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
[out]val_outthe native long object to read
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Attention
this api-function is NOT portable
See also
bus.WriteLONG(long val)

bus.ReadL_END()

TOP

END read a list-item-type from the MkBufferStreamC … → API: javamsgque.mkkernel.MkBufferStreamC.ReadL_END

bus.ReadL_START(?MkBufferC buf = null?)

TOP

START read a list-item-type from the MkBufferStreamC … → API: javamsgque.mkkernel.MkBufferStreamC.ReadL_START

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
[in]bufNULL or a MkBufferC with a list-item-type or an error is raised.
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR

bus.ReadUndo()

TOP

undo the last MkBufferStreamC READ function call … → API: javamsgque.mkkernel.MkBufferStreamC.ReadUndo

Decrement the current-access-position by one, to the start of the last read body-item. The next read function call will extract the same item again. Only one undo level is supported.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR

bus.ReadTT()

The BufferStreamReadTT provide a single function for every PRIMITIVE TYPE

returncommand

C-API :

byte[] bus.ReadB()MkBufferStreamReadB_RT
String bus.ReadC()MkBufferStreamReadC_RT
double bus.ReadD()MkBufferStreamReadD_RT
float bus.ReadF()MkBufferStreamReadF_RT
int bus.ReadI()MkBufferStreamReadI_RT
MkBufferListC bus.ReadL()MkBufferStreamReadL_RT
boolean bus.ReadO()MkBufferStreamReadO_RT
MkBufferC bus.ReadU()MkBufferStreamReadU_RT
long bus.ReadW()MkBufferStreamReadW_RT
byte bus.ReadY()

MkBufferStreamReadY_RT

read a val_out from the MkBufferStreamC

The MkBufferStreamReadTT style of functions always return a val_out or a MkErrorC.

Precondition
The val_out can be a PRIMITIVE TYPE, a class-type or a pointer-type (binary, string etc).
After every read the current-access-position is incremented by one to get the next item for the next read.
To reset the current-access-position to the start use bus.PosToStart().
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
[out]val_outthe new value

MkBufferStreamC TOR

C-API: MkBufferStreamC_TOR_C_API - various functions to create and destroy a MkBufferStreamC

[constructor] MkBufferStreamC.Create(?int size = 0?)

TOP

create and initialize an MkBufferStreamC instance … → API: javamsgque.mkkernel.MkBufferStreamC.Create

The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferStreamDelete is always possible, but the instance can no longer be used afterwards.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]typeA type defined as MkTypeS with a TT postfix (default: MkBufferStream1024S, possible: MkBufferStream16384S, MkBufferStream256S, MkBufferStream64S and MkBufferStream1024S)
[in]sizeThe initial size of the instance-local-storage. The MkBufferStreamC has dynamic-memory-management, the size value is just a hint to provide enought memory for future tasks. The real size created is the maximum of type-ILS-size and size . (default: 0 = use the type-ILS-size)
Returns
The newly created MkBufferStreamC instance, the instance is owned by the caller

[constructor] MkBufferStreamC.Create1024(?int size = 0?)

TOP

call the BufferStreamCreate with default type MkBufferStream1024S (1024 byte) … → API: javamsgque.mkkernel.MkBufferStreamC.Create1024

[constructor] MkBufferStreamC.Create16384(?int size = 0?)

TOP

call the BufferStreamCreate with default type MkBufferStream16384S (16384 byte) … → API: javamsgque.mkkernel.MkBufferStreamC.Create16384

[constructor] MkBufferStreamC.Create256(?int size = 0?)

TOP

call the BufferStreamCreate with default type MkBufferStream256S (256 byte) … → API: javamsgque.mkkernel.MkBufferStreamC.Create256

[constructor] MkBufferStreamC.Create64(?int size = 0?)

TOP

call the BufferStreamCreate with default type MkBufferStream64S (64 byte) … → API: javamsgque.mkkernel.MkBufferStreamC.Create64

[constructor] MkBufferStreamC.CreateTLS(int tlsid)

TOP

same as BufferStreamCreate but require no cleanup … → API: javamsgque.mkkernel.MkBufferStreamC.CreateTLS

A TLS-instance only exists ONCE per thread and per TLS-function in memory. The memory will be reused and must not be freed.

The new BufferStreamCreateTLS instance is ready to use and does NOT require a BufferStreamReset first and a BufferStreamDelete last.

By default the MkBufferStream64S type is used as an array of references (struct MkBufferStream64S and not struct MkBufferStream64S *). If the memory requirement exceed the predefined-storage of the MkBufferStream64S the memory is allocated on the heap.

Example from perfserver.java performance test with TLS storage

  class BUST implements ICallback {
    public void Callback(MqContextC ctx) {
      MkBufferStreamC bus = MkBufferStreamC.CreateTLS(0);
      while (ReadItemExists()) {
        bus.WriteU(ReadU());
      }
      bus.PosToStart();
      SendSTART();
      while (bus.ReadItemExists()) {
        SendU(bus.ReadU());
      }
      SendRETURN();
    }
  }
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]tlsidAn per-thread unique name (integer > 0) to identify the reuse-able instance-storage. The tlsid have to be between: 0 <= tlsid < 32
Returns
the new MkBufferStreamC instance, the instance belongs to the TLS-function and does not need to be deleted.
Attention
for usage of the TLS-storage read more at StorageCreateTLS

[static] MkBufferStreamC MkBufferStreamC.FromHandle(long exporthdl)

TOP

Import-Slot - returns a obj from a former exported handle → API: javamsgque.mkkernel.MkBufferStreamC.FromHandle

Parameters
[in]exporthdlhandle former exported with ObjectToHandle
Returns
the required handle or NULL if handle is invalid

[destructor] bus.Delete()

TOP

Destructor - delete a MkBufferStreamC instance … → API: MkBufferStreamDelete_RT

There are two different ways to delete an instance:

ObjectDisposeto free the internal data but keep the outher shell alive - this is called a SOFT-DELETE
ObjectDelete to delete the outher shell including the internal data - this is called a HARD-DELETE
Attention
  1. The internal memory will be freed and the object-pointer will be set to NULL. If the object-pointer is already NULL nothing will be done.
  2. For a programming language without HARD-Delete support, the "Delete" method is assigned to a SOFT-Delete.
  3. For a programming language without garbage collection, a SOFT-delete without a HARD-delete causes a small memory loss (C++: ~32 bytes).
  4. After a SOFT-delete, the outher shell is still alive, but cannot be used. Any access to this shell generates an HDL-null-exception, but this exception can be caught. This is important for C++ as it prevents a core dump.
  5. On HARD-delete read more at SelfDeleteForce
See also
BufferStreamCreate BufferStreamDup

[constructor] src.Dup()

TOP

Dup-Constructor - create a new MkBufferStreamC instance as copy from an existing MkBufferStreamC instance … → API: javamsgque.mkkernel.MkBufferStreamC.Dup

The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferStreamDelete is always possible, but the instance can no longer be used afterwards.

Returns
The newly created MkBufferStreamC instance, the instance is owned by the caller
See also
ObjDup BufferStreamDelete

[constructor] bus.Merge()

TOP

Merge-Constructor - create a new MkBufferStreamC as a merge from an existing object … → API: javamsgque.mkkernel.MkBufferStreamC.Merge

The Merge-Constructor create a new instance and merge all internal data from the src into the new instance. After the Merge-Constructor the BufferStreamResetFull is called for the merge-source bus.

One usage of the Merge-Constructor is to get a lightweight-copy of a Thread-Local-Storage object for external usage.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on - (nonnull)
Returns
The new instance or NULL on error or if no Merge-Constructor is available
Attention
The new instance have to be deleted with BufferStreamDelete
See also
BufferStreamDup BufferStreamResetFull BufferStreamDelete

MkBufferStreamC WRITE

C-API: MkBufferStreamC_Write_C_API - various functions to write into a MkBufferStreamC

Write is done at the position of MkBufferStreamS::storage->cur. After write the cur is incemented with write-sizeof characters.

bus.WriteLONG(long val)

TOP

write the long native object into the MkBufferStreamC … → API: javamsgque.mkkernel.MkBufferStreamC.WriteLONG

on 64bit use a BufferStreamWriteW and on 32bit use a BufferStreamWriteI

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
[in]valthe native long object to write
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Attention
this api-function is NOT portable
See also
long bus.ReadLONG()

bus.WriteL_END()

TOP

END write a list-item-type into the MkBufferStreamC … → API: javamsgque.mkkernel.MkBufferStreamC.WriteL_END

bus.WriteL_FLAT(MkBufferListC bfl)

TOP

write a MkBufferListC FLAT into the MkBufferStreamC … → API: javamsgque.mkkernel.MkBufferStreamC.WriteL_FLAT

A MkBufferListC can be written into a MkBufferStreamC using:

command description example
BufferStreamWriteL one item as list-item-type … [ itm1 itm2 itm3 itm4 ] …
BufferStreamWriteL_FLAT a sequence of single items … itm1 itm2 itm3 itm4 …

The second is called FLAT because the shell of the list-item-type is missing .

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
[in]bflthe MkBufferListC to insert
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
See also
BufferStreamReadL BufferStreamReadL

bus.WriteL_START()

TOP

START write a list-item-type into the MkBufferStreamC … → API: javamsgque.mkkernel.MkBufferStreamC.WriteL_START

bus.WriteTT(byte val)

The BufferStreamWriteTT provide a single function for every PRIMITIVE TYPE

returncommand

C-API :

bus.WriteB(byte[] val)MkBufferStreamWriteB_RT
bus.WriteC(String val)MkBufferStreamWriteC_RT
bus.WriteD(double val)MkBufferStreamWriteD_RT
bus.WriteF(float val)MkBufferStreamWriteF_RT
bus.WriteI(int val)MkBufferStreamWriteI_RT
bus.WriteL(MkBufferListC bfl)MkBufferStreamWriteL_RT
bus.WriteO(boolean val)MkBufferStreamWriteO_RT
bus.WriteU(MkBufferC val)MkBufferStreamWriteU_RT
bus.WriteW(long val)MkBufferStreamWriteW_RT
bus.WriteY(byte val)

MkBufferStreamWriteY_RT

write a PRIMITIVE TYPE into the MkBufferStreamC

After every write the current-access-position is incremented by one, use bus.Reset() to reset.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
[in]valthe new PRIMITIVE TYPE
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR

MkBufferListC

MkBufferListC APPEND

AppendGappend a native PRIMITIVE TYPE object to a MkBufferListC
AppendLAappend a variable number of MkBufferC object's to an MkBufferListC object using an other MkBufferListC OR a list of arguments (only in NON String)
AppendLPcopy a MkBufferListS list into an MkBufferListS object on position
AppendUPappend a MkBufferC item into an MkBufferListC object on position
AppendTTappend a native PRIMITIVE TYPE object to a MkBufferListC
PositionMerge

merge a MkBufferListS list into an MkBufferListS object on position

MkBufferListC CHECK

CheckOptionsearch for boolean option in MkBufferListS list and return MK_BOL value …
CheckOptionTT

search for opt in MkBufferListS list and fill var with opt_argument or the defval value …

MkBufferListC INDEX

IndexDeletedelete the index'th list item from the MkBufferListS object …
IndexExtractextract (read & delete) the index object from bfl
IndexGetget (read only) the index object from bfl
IndexGetCget the index element from MkBufferListC ... as string. …
IndexGetUget the index element from MkBufferListC ... if not available… create it. …
IndexSetset the index object from bfl
IndexSetCset the index element from MkBufferListC ... to string… if not available… create space …
IndexSetUset the index element from MkBufferListC ... if not available… createspace …
Reservereserve num items in a MkBufferListC object …
Size

get the number-of-items in the bfl

MkBufferListC INTROSPECTION

Instancesget head-instance from linked-list of MkBufferListS type …
Nextget next instance from linked-list of MkBufferListS type
Prev

get previous instance from linked-list of MkBufferListS type

MkBufferListC LOG

Logwrite the detail-summary of the MkBufferListC to MkLogFileC (default: stderr) …
LogSwrite the short-summary of the MkBufferListC to MkLogFileC (default: stderr) …
LogSSwrite the very-short-summary of the MkBufferListC to MkLogFileC (default: stderr) …
LogSSS

write the very-very-short-summary of the MkBufferListC to MkLogFileC (default: stderr) …

MkBufferListC MISC

Cmpcompare two buffer-list
Copycopy all internal data from src to tgt
Movemove all internal data from from to the end of to
Resetreset a MkBufferListC object …
SearchCsearch MK_STR item from a MkBufferListS object starting at startindex
Sortsort a MkBufferListC
ToBuffer

Export a bfl into an MkBufferC using an MkBufferStreamC

MkBufferListC TOR

CreateConstructs a MkBufferC instance with size storage…
CreateLAConstructs a MkBufferListC instance with an other MkBufferListC OR a list of arguments (only in NON String)
CreateTLSsame as BufferListCreate but require no cleanup …
FileGlobcreate a new MkBufferListC using the result from a filesystem glob operation …
FromHandleImport-Slot - returns a obj from a former exported handle
DeleteDestructor - delete a MkBufferListC instance …
DupDup-Constructor - create a new MkBufferListC instance as copy from an existing MkBufferListC instance …
Merge

Merge-Constructor - constructs a MkBufferListC instance as a merge from an existing MkBufferListC instance …

MkBufferListC DETAIL

C-API: MkBufferListC_C_API - The MkBufferListC object known as bfl or buffer-list is used to create and manage a list of MkBufferC

The MkBufferListC is used to store a list of MkBufferC data into an array. In contrast to the MkBufferStreamC, each individual item can be accessed directly with the MkBufferListC.

MkBufferListC CLASS

The CLASS used to store a list of MkBufferS items into a flat array…

C-Kernel-Details

The CLASS MkBufferListS is used to store a list of MkBufferS into an MkBufferListS::data array. To access an MkBufferS item use:

‍0 <= index < MkBufferListS::cursize

A new MkBufferListS is always preallocated with the predefined ILS-storage (MkBufferListS::bls), but can switch to a MALLOC-storage if the storage requirements of the user exceed the predefined ILS-storage-size (MkBufferListS_bls_size).

‍A MkBufferListS never run out of storage.

See also
MkBufferC, MkBufferStreamC

MkBufferListC CTOR / DTOR

command alias
[constructor] MkBufferListC.Create(?int size = 0?) javamsgque.mkkernel.MkBufferListC(int num = 0)
[destructor] bfl.Delete() bfl.Dispose()

MkBufferListC APPEND

C-API: MkBufferListC_Append_C_API - various functions to 'append' on a MkBufferListC

bfl.AppendG(long val)

TOP

append a native PRIMITIVE TYPE object to a MkBufferListC … → API: javamsgque.mkkernel.MkBufferListC.AppendG

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]valthe PRIMITIVE TYPE object data to append

MkBufferListC bfl.AppendLA(MkBufferListC args)

TOP

append a variable number of MkBufferC object's to an MkBufferListC object using an other MkBufferListC OR a list of arguments (only in NON String) → API: javamsgque.mkkernel.MkBufferListC.AppendLA

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]argsthe MkBufferListC object

MkBufferListC bfl.AppendLP(MkBufferListC addBufL, ?int position = -1?)

TOP

copy a MkBufferListS list into an MkBufferListS object on position … → API: javamsgque.mkkernel.MkBufferListC.AppendLP

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]addBufLthe MkBufferListS object to append
[in]positioninsert in at position, shift all following arguments one up
Attention
Set position to 0 to append to the beginning or set position to -1 to append to the end

bfl.AppendUP(MkBufferC addBuf, ?int position = -1?)

TOP

append a MkBufferC item into an MkBufferListC object on position … → API: javamsgque.mkkernel.MkBufferListC.AppendUP

- set position to 0 to append to the beginning

  • set position to -1 to append to the end
  • after append the addBuf belongs to bfl
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]addBufthe MkBufferC object to append
[in]positioninsert in at position, shift all following arguments one up
Attention
After append the object addBuf will be owned by bfl.

MkBufferListC bfl.PositionMerge(MkBufferListC source, int position)

TOP

merge a MkBufferListS list into an MkBufferListS object on position … → API: javamsgque.mkkernel.MkBufferListC.PositionMerge

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]sourcethe object to be merged into bfl, afterwords the source is empty and can be deleted
[in]positioninsert in at position, shift all following arguments one up. Set position to 0 to append to the beginning or set position to -1 to append to the end

bfl.AppendTT(byte val)

The BufferListAppendTT provide a single function for every PRIMITIVE TYPE

returncommand

C-API :

bfl.AppendC(String val)MkBufferListAppendC_RT
bfl.AppendD(double val)MkBufferListAppendD_RT
bfl.AppendF(float val)MkBufferListAppendF_RT
bfl.AppendI(int val)MkBufferListAppendI_RT
bfl.AppendO(boolean val)MkBufferListAppendO_RT
bfl.AppendS(short val)MkBufferListAppendS_RT
bfl.AppendU(MkBufferC val)MkBufferListAppendU_RT
bfl.AppendW(long val)MkBufferListAppendW_RT
bfl.AppendY(byte val)

MkBufferListAppendY_RT

append a native PRIMITIVE TYPE object to a MkBufferListC

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]valthe PRIMITIVE TYPE object data to append

MkBufferListC CHECK

C-API: MkBufferListC_Check_C_API - various functions to 'check' a MkBufferListC

This functions are used for parsing command-line-arguments.

boolean bfl.CheckOption(String opt, ?boolean onlyFirst = false?)

TOP

search for boolean option in MkBufferListS list and return MK_BOL value … → API: javamsgque.mkkernel.MkBufferListC.CheckOption

-# If opt is found, the opt is deleted from the MkBufferListC.

  1. If opt starting with a - or a -- the opt is treated as true
  2. If opt starting with a + or a ++ the opt is treated as false
  3. If opt does not start with a - or a + than the opt is treated as true
  4. It multiple opt are available all opt are checked and deleted.
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on or NULL
[in]optFind opt string in the MkBufferListC
[in]onlyFirstStop after first item was found

bfl.CheckOptionTT(String opt, ?byte defval = 0?, ?boolean onlyFirst = true?)

The BufferListCheckOptionTT provide a single function for every PRIMITIVE TYPE

returncommand

C-API :

String bfl.CheckOptionC(String opt, ?String defval = ""?, ?boolean onlyFirst = true?)MkBufferListCheckOptionC_RT
double bfl.CheckOptionD(String opt, ?double defval = 0?, ?boolean onlyFirst = true?)MkBufferListCheckOptionD_RT
float bfl.CheckOptionF(String opt, ?float defval = 0?, ?boolean onlyFirst = true?)MkBufferListCheckOptionF_RT
int bfl.CheckOptionI(String opt, ?int defval = 0?, ?boolean onlyFirst = true?)MkBufferListCheckOptionI_RT
boolean bfl.CheckOptionO(String opt, ?boolean defval = false?, ?boolean onlyFirst = true?)MkBufferListCheckOptionO_RT
short bfl.CheckOptionS(String opt, ?short defval = 0?, ?boolean onlyFirst = true?)MkBufferListCheckOptionS_RT
MkBufferC bfl.CheckOptionU(String opt, ?MkBufferC defval = null?, ?boolean onlyFirst = true?)MkBufferListCheckOptionU_RT
long bfl.CheckOptionW(String opt, ?long defval = 0?, ?boolean onlyFirst = true?)MkBufferListCheckOptionW_RT
byte bfl.CheckOptionY(String opt, ?byte defval = 0?, ?boolean onlyFirst = true?)

MkBufferListCheckOptionY_RT

search for opt in MkBufferListS list and fill var with opt_argument or the defval value …

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on or NULL
[in]optFind opt string in the MkBufferListC
[in]defvalThe value used if opt was not found
[in]onlyFirstIf more than one opt is available, return only the first (true [DEFAULT]) or the last (false)
[out]val_outIf opt is found, return the argument from opt otherwise defval
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Attention
  • If val_out is NULL an error is returned.
  • If the opt is found but no opt_argument than a error is returned.
  • If the opt is found, the opt and the opt_argument are deleted from the MkBufferListC.
  • If the defval is returned only a copy of the defval is returned and not the original defval.

MkBufferListC INDEX

C-API: MkBufferListC_Index_C_API - various functions to access a MkBufferListC by 'index' …

bfl.IndexDelete(int index, ?int numitems = 1?, ?boolean doDelete = true?)

TOP

delete the index'th list item from the MkBufferListS object … → API: javamsgque.mkkernel.MkBufferListC.IndexDelete

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]indexan integer index to access an object in an array by position, start=0, end=-1
numitemsdelete number of items
doDeleteif doDelete == true delete the MkBufferC object, associated with the index, too
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR

MkBufferC bfl.IndexExtract(?int index = 0?)

TOP

extract (read & delete) the index object from bfl … → API: javamsgque.mkkernel.MkBufferListC.IndexExtract

If the index is not available, this is an error

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]indexan integer index to access an object in an array by position, start=0, end=-1
[out]val_outthe MkBuffer64S object to return
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Attention
1. val_out is owned by the caller and have to be freed.
2. val_out will allways be set to NULL first.
See also
BufferListDelete

MkBufferC bfl.IndexGet(int index)

TOP

get (read only) the index object from bfl … → API: javamsgque.mkkernel.MkBufferListC.IndexGet

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]indexan integer index to access an object in an array by position, start=0, end=-1
[out]val_outthe MkBufferC to return
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Attention
1. val_out is owned by the MkBufferListC and must NOT be freed.
2. val_out will allways be set to NULL first.
3. it is an error if index is not available.
See also
BufferListIndexGetU

String bfl.IndexGetC(int index)

TOP

get the index element from MkBufferListC ... as string. … → API: javamsgque.mkkernel.MkBufferListC.IndexGetC

for details please refer to BufferListIndexGetU.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]indexan integer index to access an object in an array by position, start=0, end=-1
Returns
the string requested or an EMPTY-STRING on error

MkBufferC bfl.IndexGetU(int index)

TOP

get the index element from MkBufferListC ... if not available… create it. … → API: javamsgque.mkkernel.MkBufferListC.IndexGetU

The buffer returned is still owned by bfl.

index starting first next... mode
+0 < idx < (+)~ begin 0 1, 2, 3 ... access idx from begin
-1 < idx < (-)~ end -1 -2, -3, -4 ... append idx to the end
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]indexan integer index to access an object in an array by position, start=0, end=-1
Returns
the MkBufferC requested
See also
BufferListIndexGet

bfl.IndexSet(int index, MkBufferC buf)

TOP

set the index object from bfl … → API: javamsgque.mkkernel.MkBufferListC.IndexSet

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]indexan integer index to access an object in an array by position, start=0, end=-1
[in]bufthe MkBufferS instance to work on
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Attention
It is an error if index is not available.
See also
BufferListIndexSetU

bfl.IndexSetC(int index, String str)

TOP

set the index element from MkBufferListC ... to string… if not available… create space … → API: javamsgque.mkkernel.MkBufferListC.IndexSetC

for details please refer to BufferListIndexGetU

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]indexan integer index to access an object in an array by position, start=0, end=-1
[in]strthe string to set

bfl.IndexSetU(int index, MkBufferC buf)

TOP

set the index element from MkBufferListC ... if not available… createspace … → API: javamsgque.mkkernel.MkBufferListC.IndexSetU

-# cursize will be >= index+1

  1. size will be >= index+1
  2. cursize <= X < index+1 -> the missing buffer will be created
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]indexan integer index to access an object in an array by position, start=0, end=-1
[in]bufthe MkBufferS instance to work on

bfl.Reserve(int num)

TOP

reserve num items in a MkBufferListC object … → API: javamsgque.mkkernel.MkBufferListC.Reserve

-# cursize will be num

  1. size will b >= num
  2. free: num <= X < cursize
  3. init: cursize <= X < num
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
bflthe MkBufferListC object to reserve memory
numreserve the number of items for later use.

int bfl.Size()

TOP

get the number-of-items in the bfl … → API: javamsgque.mkkernel.MkBufferListC.Size

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
Returns
the number-of-items in the bfl

MkBufferListC INTROSPECTION

C-API: MkBufferListC_Introspection_C_API - Get information from the MkTypeS.

Get information about all instances created by class

Get information about all instances created by class

The Introspection API is used to get information about the details of the instance and type implementation. Only the connection between type and instance is currently implemented.

Three methods are used to create an iteration over all avaialable instances of a type.

  • Every class has a Linked-List of all instances created starting from last to first.
  • The Introspection support always 3 Functions per class: Instance (static), Next and Prev
  • The Instance (example: [static] MkBufferC MkBufferC.Instances())
    • return the last-instance created or null if no instance was created.
  • The Next (example: MkBufferC buf.Next())
    • return the next-instance for a given-instance or null if the given-instance is the last-instance.
  • The Prev (example: MkBufferC buf.Prev())
    • return the previous-instance for a given-instance or null if the given-instance is the first-instance.

Example: a simple loop over all instances of class MkBufferC (language C++)

for (auto buf = MkBufferC::Instances(); buf != NULL; buf = buf->Next()) {
SendC(buf->ToString());
}

[static] MkBufferListC MkBufferListC.Instances()

TOP

get head-instance from linked-list of MkBufferListS type … → API: javamsgque.mkkernel.MkBufferListC.Instances

The head-instance is the last instance created.

MkBufferListC bfl.Next()

TOP

get next instance from linked-list of MkBufferListS type → API: javamsgque.mkkernel.MkBufferListC.Next

MkBufferListC bfl.Prev()

TOP

get previous instance from linked-list of MkBufferListS type → API: javamsgque.mkkernel.MkBufferListC.Prev

MkBufferListC LOG

C-API: MkBufferListC_Log_C_API - various functions to 'log' a MkBufferListC

bfl.Log(?MkObjectC fmtobj = null?, ?int debug = 0?, ?String callfunc = null?, ?int lvl = 0?)

TOP

write the detail-summary of the MkBufferListC to MkLogFileC (default: stderr) … → API: javamsgque.mkkernel.MkBufferListC.Log

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]lvla user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0)
See also
MkBufferListC

bfl.LogS(?String varname = "bfl"?, ?MkObjectC fmtobj = null?, ?String callfunc = null?)

TOP

write the short-summary of the MkBufferListC to MkLogFileC (default: stderr) … → API: javamsgque.mkkernel.MkBufferListC.LogS

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
varnameprefix to identify the variable name
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)

bfl.LogSS(?String varname = "bfl"?, ?MkObjectC fmtobj = null?, ?String callfunc = null?)

TOP

write the very-short-summary of the MkBufferListC to MkLogFileC (default: stderr) … → API: javamsgque.mkkernel.MkBufferListC.LogSS

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
varnameprefix to identify the variable name
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)

bfl.LogSSS(?String varname = "bfl"?, ?MkObjectC fmtobj = null?, ?String callfunc = null?)

TOP

write the very-very-short-summary of the MkBufferListC to MkLogFileC (default: stderr) … → API: javamsgque.mkkernel.MkBufferListC.LogSSS

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]varnameThe name of the argument to report
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)

MkBufferListC MISC

C-API: MkBufferListC_Misc_C_API - various functions to work on a MkBufferListC

int bfl.Cmp(MkBufferListC bfl2)

TOP

compare two buffer-list … → API: javamsgque.mkkernel.MkBufferListC.Cmp

First the size is compared and if the size is equal every argument starting from 0 is compared with BufferCmp. The first BufferCmp with a result != 0 finish the comparison and this result is returned.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]bfl2buffer-list to compare
Returns
Returns < 0 if bfl is less than bfl2; > 0 if bfl is greater than bfl2, and 0 if they are equal

bfl.Copy(MkBufferListC src)

TOP

copy all internal data from src to tgt … → API: javamsgque.mkkernel.MkBufferListC.Copy

-# existing data will be overwritten

  1. the cursize of src will be the cursize of tgt
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]srcthe source of the copy

to.Move(MkBufferListC from)

TOP

move all internal data from from to the end of to … → API: javamsgque.mkkernel.MkBufferListC.Move

after the move… the from ist empty and only the shell exists

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]tothe target of the move
[in]fromthe source of the move

bfl.Reset()

TOP

reset a MkBufferListC object … → API: javamsgque.mkkernel.MkBufferListC.Reset

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
Attention
all MkBufferC objects will be freed

int bfl.SearchC(String str, ?int len = -1?, ?int startindex = 0?)

TOP

search MK_STR item from a MkBufferListS object starting at startindex … → API: javamsgque.mkkernel.MkBufferListC.SearchC

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
strthe string to search for
lenthe length of str or -1 to calulate the length with strlen
startindexstart searching in buf from index startindex
Returns
The index of the str found or -1 if not found. The return value can be used as startindex of following calls to BufferListSearchC

a typical usage for this code is parsing an MkBufferListS object for multiple occurrences of a string

while ((startindex = MkBufferListSearchC (buf, str, strlen(str), startindex)) != -1) {
...
}
Attention
The size of str have to be at least 4 bytes

MkBufferListC bfl.Sort()

TOP

sort a MkBufferListC … → API: javamsgque.mkkernel.MkBufferListC.Sort

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
Returns
Return the input bfl as sorted list

MkBufferC bfl.ToBuffer()

TOP

Export a bfl into an MkBufferC using an MkBufferStreamC … → API: javamsgque.mkkernel.MkBufferListC.ToBuffer

An buffer is able to hold all primitive types and LIST of primitive types. An buffer-list is an Indexed-LIST representation of a LIST of buffer.

To add a buffer-list into an buffer the buffer-list have to be converted into a buffer-stream and the buffer-stream have to be exported as buffer. The buffer is finally apended to the buffer-list.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
Returns
the required buffer or a NULL on error
Attention
The memory of the out-value belongs to the called JavaMkKernel function and therefore never becomes null. For details on the out-value, see: MkKernel_Storage_C_API.

MkBufferListC TOR

C-API: MkBufferListC_TOR_C_API - various functions to create and destroy a MkBufferListC

[constructor] MkBufferListC.Create(?int size = 0?)

TOP

Constructs a MkBufferC instance with size storage… → API: javamsgque.mkkernel.MkBufferListC.Create

The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferListDelete is always possible, but the instance can no longer be used afterwards.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]sizeThe initial size of the instance-local-storage. The MkBufferListC has dynamic-memory-management, the size value is just a hint to provide enought memory for future tasks. The real size created is the maximum of type-ILS-size and size . (default: 0 = use the type-ILS-size)
Returns
The newly created MkBufferListC instance, the instance is owned by the caller

[constructor] MkBufferListC.CreateLA(MkBufferListC args)

TOP

Constructs a MkBufferListC instance with an other MkBufferListC OR a list of arguments (only in NON String) → API: javamsgque.mkkernel.MkBufferListC.CreateLA

The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferListDelete is always possible, but the instance can no longer be used afterwards.

Returns
The newly created MkBufferListC instance, the instance is owned by the caller
See also
BufferListDup

[constructor] MkBufferListC.CreateTLS(int tlsid)

TOP

same as BufferListCreate but require no cleanup … → API: javamsgque.mkkernel.MkBufferListC.CreateTLS

A TLS-instance only exists ONCE per thread and per TLS-function in memory. The memory will be reused and must not be freed.

The new BufferListCreateTLS instance is ready to use and does NOT require a BufferListReset first and a BufferListDelete last.

By default a MkBufferListS type is created because internal an array of references is used and no "malloc" etc is done. ONLY if the required size extend the MkBufferListS prealloc size the storage-manager switch internal to dynamic storage management.

Example from perfserver.java performance test with TLS storage

class BFLT implements ICallback {
public void Callback(MqContextC ctx) {
MkBufferListC bfl = MkBufferListC.CreateTLS(0);
while (ReadItemExists()) {
bfl.AppendU(ReadU());
}
SendSTART();
IntStream.range(0, bfl.Size()).forEach(
i -> {
SendU(bfl.IndexGet(i));
}
);
SendRETURN();
}
}
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]tlsidAn per-thread unique name (integer > 0) to identify the reuse-able instance-storage. The tlsid have to be between: 0 <= tlsid < 32
Returns
the new MkBufferListC instance, the instance belongs to the TLS-function and does not need to be deleted.
Attention
for usage of the TLS-storage read more at StorageCreateTLS

[constructor] MkBufferListC.FileGlob(String pattern_match)

TOP

create a new MkBufferListC using the result from a filesystem glob operation … → API: javamsgque.mkkernel.MkBufferListC.FileGlob

[static] MkBufferListC MkBufferListC.FromHandle(long exporthdl)

TOP

Import-Slot - returns a obj from a former exported handle → API: javamsgque.mkkernel.MkBufferListC.FromHandle

Parameters
[in]exporthdlhandle former exported with ObjectToHandle
Returns
the required handle or NULL if handle is invalid

[destructor] bfl.Delete()

TOP

Destructor - delete a MkBufferListC instance … → API: MkBufferListDelete_RT

There are two different ways to delete an instance:

ObjectDisposeto free the internal data but keep the outher shell alive - this is called a SOFT-DELETE
ObjectDelete to delete the outher shell including the internal data - this is called a HARD-DELETE
Attention
  1. The internal memory will be freed and the object-pointer will be set to NULL. If the object-pointer is already NULL nothing will be done.
  2. For a programming language without HARD-Delete support, the "Delete" method is assigned to a SOFT-Delete.
  3. For a programming language without garbage collection, a SOFT-delete without a HARD-delete causes a small memory loss (C++: ~32 bytes).
  4. After a SOFT-delete, the outher shell is still alive, but cannot be used. Any access to this shell generates an HDL-null-exception, but this exception can be caught. This is important for C++ as it prevents a core dump.
  5. On HARD-delete read more at SelfDeleteForce
See also
BufferListCreate BufferListDup MqReadL

[constructor] bfl.Dup()

TOP

Dup-Constructor - create a new MkBufferListC instance as copy from an existing MkBufferListC instance … → API: javamsgque.mkkernel.MkBufferListC.Dup

The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferListDelete is always possible, but the instance can no longer be used afterwards.

Returns
The newly created MkBufferListC instance, the instance is owned by the caller
See also
ObjDup

[constructor] bfl.Merge()

TOP

Merge-Constructor - constructs a MkBufferListC instance as a merge from an existing MkBufferListC instance … → API: javamsgque.mkkernel.MkBufferListC.Merge

The Merge-Constructor create a new object-shell, and take-over all the internal data from the source-object. After the Merge-Constructor the source-object is empty as if a BufferListReset was called.

One usage of the Merge-Constructor is to get a lightweight-copy of a Thread-Local-Storage object for external usage.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
Returns
The new instance or NULL on error or if no Merge-Constructor is available
Attention
The new instance have to be deleted with BufferListDelete
See also
BufferListDup

MkErrorC

MkErrorC GET

GetCodeget the value of MkErrorS::code
GetNumget the MkErrorS::num. The number can be used as exit-code …
GetSizeget the error-message-size from the exception-object
GetText

get the MkErrorS::text

MkErrorC INTROSPECTION

Instancesget head-instance from linked-list of MkErrorS type …
Nextget next instance from linked-list of MkErrorS type
Prev

get previous instance from linked-list of MkErrorS type

MkErrorC MISC

Catchconvert a programming-language-error into an javamkkernel error …
Loglog the error to MkLogFileC (default: stderr) …
Printlnprint the default-error to the MkLogFileC (default: stderr) and clear the error afterwards …
ResetThis function clears the err and resets to MK_OK
Stackcheck on error and if yes append an ErrorStackFormat to the error-message
StackFormat

append an ensemble of func, file and line to the error-message

MkErrorC RAISE

PanicCdo a panic with string as argument …
AppendCappend the message to the MkErrorS::text
NoRaiseignore the next return of MK_ERROR and do not raise an target-language-exception
Raiseconvert an javamkkernel error into an programming-language-error and raise afterwards. …
SetC

'set' and 'raise' the MkErrorC using a string-message and a errnum-number

MkErrorC SIGNAL

IsEXITcheck on APPLICATION-EXIT error …
IsSOCKETcheck on SOCKET-DOWN error …
SetCONTINUEsignal end of processing in an MqIEvent callback …
SetCodeset the MkErrorS::code value …
SetEXITfinish the current callback, return to toplevel and MqExit the application …
SetSOCKET

create SOCKET-DOWN error …

MkErrorC SYSTEM

DEFAULTsystem-error - this is always the error in duty …
IGNOREsystem-error - do not store the error in an MkErrorC and ignore the error …
PRINT

system-error - print the error to the MkLogFileC

MkErrorC TOR

FromHandleImport-Slot - returns a obj from a former exported handle
DeleteDestructor - delete a MkErrorS object …
Dup

Dup-Constructor - create a new MkErrorC instance as copy from an existing MkErrorC instance …

MkErrorC DETAIL

C-API: MkErrorC_C_API - The MkErrorC object known as err or error is used to create … and manage an error message …

An error is a singleton object per thread created at startup and is located at MkRuntimeRLS using the datatype MkErrorC.

‍As error-indicator the enum MkErrorE is used.

The MkErrorC is used to collect all data needed to handle an error and provide global ressources required to process and report the error.

The MkErrorC is also used to integrate the error-handling from javamkkernel into the error-handling-code of the target Java.

Example from Filter6.java use MqContextErrorCatch to convert a Java error into a javamkkernel error

  public static void main(String[] argv) {
    MqContextC srv = MqFactoryC.Add(Filter6.class).New();
    try {
      srv.LinkCreate(argv);
      srv.ProcessEvent(MqWaitOnEventE.FOREVER);
    } catch (Throwable e) {
      srv.ErrorCatch(e);
    } finally {
      srv.Exit();
    }
  }

MkExceptionC

Object used to connect the LibMsgqueError with the target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO) error …

The LibMsgque provide with MkErrorC a complete error-handling with focus to support the "C" Programming-Language. The support include catch, raise, signal and attributes. In addition every target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO) add their own error-handling and the purpose of MkExceptionC is to integrate the MkErrorC into the target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO).

The implementation of an exception depends heavily on the target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO), starting with no exception at all, for example. C, an exception as a class object, or as an exception as a global attribute.

Attention
  • All MkExceptionC code is implemented at the target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO) without support by the Programming-Language-Micro-Kernel compiler.
  • By default, MkExceptionC is only used internally, hidden by the class MkErrorC.

ExceptionCheck

Checks if Exception is of type MkExceptionC and returns true or false

Example: test case to check KILL and RECOVER feature, check on MkExceptionC

          var VAL = ReadU();
          mycl = new Client();
          mycl.LinkCreate(ConfigGetStartAs());
          int PID = (int) mycl.Send("W", "GPID@I");
          int RET=0;
          SysKill(PID,9);
          for (int i = 0; i < 3; i++) {
            try {
              RET = (int) mycl.Send("W", "ECOI:U@I", VAL);
            } catch (MkExceptionC ex) {
              var err = mycl.ErrorCatch(ex);
              if (err.IsSOCKET()) {
                err.Reset();
                mycl.LinkConnect();
                continue;
              } else {
                err.Raise();
              }
            }
            break;
          }
          SendSTART();
          SendI(RET);
Returns
the result of the check, true or false
Parameters
[in]exceptionthe exception object from Java, if null the global exception object is used

MkErrorC GET

C-API: MkErrorC_Get_C_API - various functions to 'get' data out of MkErrorC

MkErrorE err.GetCode()

TOP

get the value of MkErrorS::code … → API: javamsgque.mkkernel.MkErrorC.GetCode

int err.GetNum()

TOP

get the MkErrorS::num. The number can be used as exit-code … → API: javamsgque.mkkernel.MkErrorC.GetNum

long err.GetSize()

TOP

get the error-message-size from the exception-object … → API: javamsgque.mkkernel.MkErrorC.GetSize

String err.GetText()

TOP

get the MkErrorS::text … → API: javamsgque.mkkernel.MkErrorC.GetText

MkErrorC INTROSPECTION

C-API: MkErrorC_Introspection_C_API - Get information from the MkTypeS.

Get information about all instances created by class

Get information about all instances created by class

The Introspection API is used to get information about the details of the instance and type implementation. Only the connection between type and instance is currently implemented.

Three methods are used to create an iteration over all avaialable instances of a type.

  • Every class has a Linked-List of all instances created starting from last to first.
  • The Introspection support always 3 Functions per class: Instance (static), Next and Prev
  • The Instance (example: [static] MkBufferC MkBufferC.Instances())
    • return the last-instance created or null if no instance was created.
  • The Next (example: MkBufferC buf.Next())
    • return the next-instance for a given-instance or null if the given-instance is the last-instance.
  • The Prev (example: MkBufferC buf.Prev())
    • return the previous-instance for a given-instance or null if the given-instance is the first-instance.

Example: a simple loop over all instances of class MkBufferC (language C++)

for (auto buf = MkBufferC::Instances(); buf != NULL; buf = buf->Next()) {
SendC(buf->ToString());
}

[static] MkErrorC MkErrorC.Instances()

TOP

get head-instance from linked-list of MkErrorS type … → API: javamsgque.mkkernel.MkErrorC.Instances

The head-instance is the last instance created.

MkErrorC err.Next()

TOP

get next instance from linked-list of MkErrorS type → API: javamsgque.mkkernel.MkErrorC.Next

MkErrorC err.Prev()

TOP

get previous instance from linked-list of MkErrorS type → API: javamsgque.mkkernel.MkErrorC.Prev

MkErrorC MISC

C-API: MkErrorC_Misc_C_API - various functions to 'work' on a MkErrorC

MkErrorC err.Catch(?Throwable exception = null?, ?String callfunc = null?)

TOP

convert a programming-language-error into an javamkkernel error … → API: javamsgque.mkkernel.MkErrorC.Catch

Same as MkErrorC obj.ErrorCatch(?Throwable exception = null?, ?String callfunc = null?) but skip the Error-Prefix in final target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO).

Example from Bug3.java catch an error using [static] MkErrorC MkErrorC.DEFAULT(?MkObjectC fmtobj = null?)

    } catch (Throwable e) {
      MkErrorC.DEFAULT().Catch(e).Println();
    }
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errthe MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed)
[in]exceptionthe exception object from Java, if null the global exception object is used
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
Returns
the ErrorDEFAULT initialized with exception value
See also
err.Raise() err.Reset(?String callfunc = null?, ?int callline = -1?, ?boolean force = false?)

err.Log(?MkObjectC fmtobj = null?, ?int debug = 0?, ?String callfunc = null?, ?int lvl = 0?)

TOP

log the error to MkLogFileC (default: stderr) … → API: javamsgque.mkkernel.MkErrorC.Log

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errthe MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed)
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]lvla user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0)
See also
MkErrorC err.Log(?MkObjectC fmtobj = null?, ?int debug = 0?, ?String callfunc = null?, ?int lvl = 0?)

err.Println()

TOP

print the default-error to the MkLogFileC (default: stderr) and clear the error afterwards … → API: javamsgque.mkkernel.MkErrorC.Println

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errthe MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed)

err.Reset(?String callfunc = null?, ?int callline = -1?, ?boolean force = false?)

TOP

This function clears the err and resets to MK_OK … → API: javamsgque.mkkernel.MkErrorC.Reset

Attention
Use this function carfully, as misuse will result in the loss of the error-message.

It is recommended that you use this feature only after the error has been processed.

  • processed = The error was send to another server or printed to the user or to a file.
See also
ErrorRaise ErrorCatch

MkErrorE err.Stack(?String callfunc = null?, ?String callfile = null?, ?int callline = -1?)

TOP

check on error and if yes append an ErrorStackFormat to the error-message … → API: javamsgque.mkkernel.MkErrorC.Stack

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errthe MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) → NULL allowed
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]callfilethe name of the file the call take place (e.g. FILE)
[in]calllinethe number of the line the call take place (e.g. LINE)
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR

err.StackFormat(?String callfunc = null?, ?String callfile = null?, ?int callline = -1?)

TOP

append an ensemble of func, file and line to the error-message … → API: javamsgque.mkkernel.MkErrorC.StackFormat

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errthe MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]callfilethe name of the file the call take place (e.g. FILE)
[in]calllinethe number of the line the call take place (e.g. LINE)

MkErrorC RAISE

C-API: MkErrorC_Raise_C_API - various functions to 'raise' a MkErrorC

An error is "raised" by naming the MkErrorS::text and changing the MkErrorS::code to MK_ERROR.

[static] MkErrorC.PanicC(?MkObjectC errobj = null?, ?String callfunc = null?, ?int errnum = -1?, String message)

TOP

do a panic with string as argument … → API: javamsgque.mkkernel.MkErrorC.PanicC

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errobja managed object used to identify and format the error-message
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]errnumthe error number used as exit-code as well
messagethe string to be displayed
Attention
this function will never return

err.AppendC(String message)

TOP

append the message to the MkErrorS::text … → API: javamsgque.mkkernel.MkErrorC.AppendC

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errthe MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed)
[in]messagethe string to be displayed as message (append)

MkErrorC err.NoRaise()

TOP

ignore the next return of MK_ERROR and do not raise an target-language-exception … → API: javamsgque.mkkernel.MkErrorC.NoRaise

Many functions from the MkErrorXXX return an MkErrorE to signal that an MK_ERROR is set. The target-language react on this signal and raise an target-language-exception.
If this behaviour is not desired the ErrorNoRaise is used to suppress the next MK_ERROR return.

This feature is used to avoid the target-language-exception after ErrorSetC etc.

This is usefull if:

  1. an error should be send by MqSendERROR later
  2. an error will be extended by using multiple ErrorAppendC etc later and than raised with ErrorRaise

Example from server.java create and send an background-error message

  public void BgError () {
    MqContextC master = SlaveGetMaster();
    if (master != null) {
      MkErrorC err = master.ErrorDEFAULT().NoRaise();
      err.SetC (err.GetText(), "BGERROR", err.GetNum());
      master.SendERROR ();
    }
  }
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errthe MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed)
Returns
the input err with MkErrorS::noRaise flag set

err.Raise()

TOP

convert an javamkkernel error into an programming-language-error and raise afterwards. … → API: javamsgque.mkkernel.MkErrorC.Raise

If ther is no javamkkernel-error (MkErrorS::code "= #MK_ERROR) than nothing happen. @param [in] err the #MkErrorS instance to work on - the \e default-error is automatically created on startup. (NULL allowed) \sa \ref doc_mk_jv_ErrorCatch "ErrorCatch" \ref doc_mk_jv_ErrorReset "ErrorReset"

err.SetC(String message, ?String callfunc = null?, ?int errnum = -1?)

TOP

'set' and 'raise' the MkErrorC using a string-message and a errnum-number … → API: javamsgque.mkkernel.MkErrorC.SetC

The message will be formatted into a javamkkernel error-message.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errthe MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) - err==NULL allowed
[in]messagethe string to be displayed as message
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]errnumthe error number used as exit-code as well
Attention
Use ErrorNoRaise to avoid raise an error.

MkErrorC SIGNAL

C-API: MkErrorC_Signal_C_API - various functions to set and check a 'signal' on a MkErrorC

boolean err.IsEXIT()

TOP

check on APPLICATION-EXIT error … → API: javamsgque.mkkernel.MkErrorC.IsEXIT

The exit-error-object is made for two resons:

  1. The error is set by ErrorSetEXIT to signal end-of-application.
  2. The error is raised by a function to signal a fatal-error which require an application-exit.
    The only source of this kind of fatal-error is a link-target-abnormal-exit caused by a server/network crash.

The link-target-abnormal-exit can only occur for functions that perform a network-request, such as:

  • MqLinkCreate, MqLinkCreateChild, MqLinkConnect, MqSendEND, MqSendEND_AND_WAIT or MqProcessEvent

The aim of this function is to react to an exit-error-object and is used to ignore the error with an ErrorReset and then later to re-establish a connection with a MqLinkConnect.

  • Read more from the: example/java/Filter4.java example

Example "C": catch and ignore an EXIT return-code

if (MkErrorCheckI (MqSendEND_AND_WAIT (ctx, "TOKS", MK_TIMEOUT_USER))) {
if (MkErrorIsEXIT_0E ()) MkErrorReset_1X (ctx);
}
#define MkErrorReset_1X(x)
#define MkErrorCheckI(err)

boolean err.IsSOCKET()

TOP

check on SOCKET-DOWN error … → API: javamsgque.mkkernel.MkErrorC.IsSOCKET

err.SetCONTINUE()

TOP

signal end of processing in an MqIEvent callback … → API: javamsgque.mkkernel.MkErrorC.SetCONTINUE

err.SetCode(MkErrorE code)

TOP

set the MkErrorS::code value … → API: javamsgque.mkkernel.MkErrorC.SetCode

err.SetEXIT(?String callfunc = null?)

TOP

finish the current callback, return to toplevel and MqExit the application … → API: javamsgque.mkkernel.MkErrorC.SetEXIT

To exit a application in a callback is a difficult task because the code is in-duty. To achieve this goal a special exit-error-object is created and reported to the toplevel. If a transaction is ongoing the MqSendRETURN is not called and thus the transaction is not finished. The calling application is informed later by a socket-down event. This only works for a parent-context. An exit in a child-context is ignored.

Example: raise an EXIT-exception in an ruby-service:

def EXIT
MkErrorC.DEFAULT().SetEXIT()
end

err.SetSOCKET(?String detail = "UNKNOWN"?, ?String callfunc = null?)

TOP

create SOCKET-DOWN error … → API: javamsgque.mkkernel.MkErrorC.SetSOCKET

MkErrorC SYSTEM

C-API: MkErrorC_System_C_API - various functions to reaise 'System' messagen on MkErrorC

[static] MkErrorC MkErrorC.DEFAULT(?MkObjectC fmtobj = null?)

TOP

system-error - this is always the error in duty … → API: javamsgque.mkkernel.MkErrorC.DEFAULT

Set the MkErrorS::format_of_error attribute to fmtobj or NULL. The next error-massage will be formated as usual and than be raised as error. The default-error will be modified.

The next error-message created with ErrorSetC etc is formatted with MkRuntimeS->cid ("context-in-duty") or simply as "DEFAULT" if cid == NULL.

Parameters
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
Returns
the default-error with MkErrorS::format_of_error attribute set
See also
ErrorDEFAULT, ErrorPRINT, ErrorIGNORE, ErrorPANIC

[static] MkErrorC MkErrorC.IGNORE()

TOP

system-error - do not store the error in an MkErrorC and ignore the error … → API: javamsgque.mkkernel.MkErrorC.IGNORE

There are two functions to suppress an error: [static] MkErrorC MkErrorC.IGNORE() and MkErrorC err.NoRaise().

The [static] MkErrorC MkErrorC.IGNORE() set the MkErrorS::format_of_error attribute to IGNORE. The next error will be ignored, no formatting will be performed and the the default-error will not be modified.

The MkErrorC err.NoRaise() set the MkErrorS::noRaise attribute to TRUE. The next error will be set as usual but not raised. This is usefull to set an error and later append additional information to the error. Final the error have to be raised with err.Raise().

Returns
the default-error with MkErrorS::format_of_error attribute set
See also
ErrorDEFAULT, ErrorPRINT, ErrorIGNORE, ErrorPANIC

[static] MkErrorC MkErrorC.PRINT()

TOP

system-error - print the error to the MkLogFileC … → API: javamsgque.mkkernel.MkErrorC.PRINT

Set the MkErrorS::format_of_error attribute to PRINT. The next error-massage will be formated as usual and than be reported using LogVL. The default-error will not be modified.

Returns
the default-error with MkErrorS::format_of_error attribute set
See also
ErrorDEFAULT, ErrorPRINT, ErrorIGNORE, ErrorPANIC

MkErrorC TOR

C-API: MkErrorC_TOR_C_API - various functions to 'create' and 'delete' a MkErrorC

[static] MkErrorC MkErrorC.FromHandle(long exporthdl)

TOP

Import-Slot - returns a obj from a former exported handle → API: javamsgque.mkkernel.MkErrorC.FromHandle

Parameters
[in]exporthdlhandle former exported with ObjectToHandle
Returns
the required handle or NULL if handle is invalid

[destructor] err.Delete()

TOP

Destructor - delete a MkErrorS object … → API: MkErrorDelete_RT

There are two different ways to delete an instance:

ObjectDisposeto free the internal data but keep the outher shell alive - this is called a SOFT-DELETE
ObjectDelete to delete the outher shell including the internal data - this is called a HARD-DELETE
Attention
  1. The internal memory will be freed and the object-pointer will be set to NULL. If the object-pointer is already NULL nothing will be done.
  2. For a programming language without HARD-Delete support, the "Delete" method is assigned to a SOFT-Delete.
  3. For a programming language without garbage collection, a SOFT-delete without a HARD-delete causes a small memory loss (C++: ~32 bytes).
  4. After a SOFT-delete, the outher shell is still alive, but cannot be used. Any access to this shell generates an HDL-null-exception, but this exception can be caught. This is important for C++ as it prevents a core dump.
  5. On HARD-delete read more at SelfDeleteForce
See also
BufferDup ObjectDelete

[constructor] srce.Dup()

TOP

Dup-Constructor - create a new MkErrorC instance as copy from an existing MkErrorC instance … → API: javamsgque.mkkernel.MkErrorC.Dup

The new instance belongs to the caller and may have to be released if necessary. A manual release using ErrorDelete is always possible, but the instance can no longer be used afterwards.

Returns
The newly created MkErrorC instance, the instance is owned by the caller
See also
ObjDup ErrorDelete

MkLogFileC

MkLogFileC INTROSPECTION

Instancesget head-instance from linked-list of MkLogFileS type …
Nextget next instance from linked-list of MkLogFileS type
Prev

get previous instance from linked-list of MkLogFileS type

MkLogFileC TOR

FromHandleImport-Slot - returns a obj from a former exported handle
Openopen the log-file in append mode …
Close

Destructor - delete a MkLogFileC instance …

MkLogFileC WRITE

GetFileget the log-file
WriteC

write to log-file

MkLogFileC DETAIL

C-API: MkLogFileC_C_API - The MkLogFileC object known as lfl or log-file is used to control … the target of the logging-output.

The logging-target is set direct by RuntimeSetLogfile or using the class MkLogFileC.

The target is stored at the MkRuntimeC using a FILE-stream and can be set individually for each thread. The default is stderr.

possible values are:

value decription OS man-page
stdout the standart output stdio(3)
stderr the standart error output stdio(3)
fileName an arbitary fileName fopen(3)

MkLogFileC INTROSPECTION

C-API: MkLogFileC_Introspection_C_API - Get information from the MkTypeS.

Get information about all instances created by class

Get information about all instances created by class

The Introspection API is used to get information about the details of the instance and type implementation. Only the connection between type and instance is currently implemented.

Three methods are used to create an iteration over all avaialable instances of a type.

  • Every class has a Linked-List of all instances created starting from last to first.
  • The Introspection support always 3 Functions per class: Instance (static), Next and Prev
  • The Instance (example: [static] MkBufferC MkBufferC.Instances())
    • return the last-instance created or null if no instance was created.
  • The Next (example: MkBufferC buf.Next())
    • return the next-instance for a given-instance or null if the given-instance is the last-instance.
  • The Prev (example: MkBufferC buf.Prev())
    • return the previous-instance for a given-instance or null if the given-instance is the first-instance.

Example: a simple loop over all instances of class MkBufferC (language C++)

for (auto buf = MkBufferC::Instances(); buf != NULL; buf = buf->Next()) {
SendC(buf->ToString());
}

[static] MkLogFileC MkLogFileC.Instances()

TOP

get head-instance from linked-list of MkLogFileS type … → API: javamsgque.mkkernel.MkLogFileC.Instances

The head-instance is the last instance created.

MkLogFileC lfl.Next()

TOP

get next instance from linked-list of MkLogFileS type → API: javamsgque.mkkernel.MkLogFileC.Next

MkLogFileC lfl.Prev()

TOP

get previous instance from linked-list of MkLogFileS type → API: javamsgque.mkkernel.MkLogFileC.Prev

MkLogFileC TOR

C-API: MkLogFileC_TOR_C_API - various functions to 'create and delete' a MkLogFileC

[static] MkLogFileC MkLogFileC.FromHandle(long exporthdl)

TOP

Import-Slot - returns a obj from a former exported handle → API: javamsgque.mkkernel.MkLogFileC.FromHandle

Parameters
[in]exporthdlhandle former exported with ObjectToHandle
Returns
the required handle or NULL if handle is invalid

[constructor] MkLogFileC.Open(MkObjectC errobj, String file)

TOP

open the log-file in append mode … → API: javamsgque.mkkernel.MkLogFileC.Open

The new instance belongs to the caller and may have to be released if necessary. A manual release using LogFileClose is always possible, but the instance can no longer be used afterwards.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errobja managed object used to identify and format the error-message
[in]filethe filename to open
[out]lfh_outreturns
Returns
The newly created MkLogFileC instance, the instance is owned by the caller
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Attention
on error the lfh_out is set to NULL

[destructor] lfh.Close()

TOP

Destructor - delete a MkLogFileC instance … → API: MkLogFileClose_RT

There are two different ways to delete an instance:

ObjectDisposeto free the internal data but keep the outher shell alive - this is called a SOFT-DELETE
ObjectDelete to delete the outher shell including the internal data - this is called a HARD-DELETE
Attention
  1. The internal memory will be freed and the object-pointer will be set to NULL. If the object-pointer is already NULL nothing will be done.
  2. For a programming language without HARD-Delete support, the "Delete" method is assigned to a SOFT-Delete.
  3. For a programming language without garbage collection, a SOFT-delete without a HARD-delete causes a small memory loss (C++: ~32 bytes).
  4. After a SOFT-delete, the outher shell is still alive, but cannot be used. Any access to this shell generates an HDL-null-exception, but this exception can be caught. This is important for C++ as it prevents a core dump.
  5. On HARD-delete read more at SelfDeleteForce
See also
LogFileOpen

MkLogFileC WRITE

C-API: MkLogFileC_Write_C_API - various functions to 'write' into a MkLogFileC

String lfl.GetFile()

TOP

get the log-file … → API: javamsgque.mkkernel.MkLogFileC.GetFile

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]lflthe MkLogFileS instance to work on
[out]file_outthe log-file to return
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR

lfl.WriteC(String text)

TOP

write to log-file … → API: javamsgque.mkkernel.MkLogFileC.WriteC

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]lflthe MkLogFileS instance to work on
[in]textthe text to write
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR

MkRuntimeC

MkRuntimeC CONFIG

Debuglog the MkRuntimeC
GetDebugget the MkRuntimeS::debug value …
GetIsSilentget the MkRuntimeS::isSilent value …
GetLogfileget the MkRuntimeS::logfile value …
SetDebugset the MkRuntimeS::debug value …
SetIsSilentset the MkRuntimeS::isSilent value …
SetLogfile

set the MkRuntimeS::logfile value and cleanup old value …

MkRuntimeC DETAIL

C-API: MkRuntimeC_C_API - The MkRuntimeC class known as mkrt or runtime is the main javamkkernel application environment …

The runtime is automatically created as thread-local-storage at startup, so that each new thread receives a thread-specific runtime. Each instance on this thread has a link to the runtime it was created in:

The runtime provide the following features:

  • the default-error -> MkErrorC
  • the runtime local storage (RLS) for various internal features
  • application wide configuration data like debug logfile or silent

MkRuntimeC CONFIG

C-API: MkRuntimeC_Config_C_API - only C - various functions to configure the MkRuntimeC

The MkRuntimeRLS-configuration belongs to a single MkRuntimeRLS. In a threadable application, each thread has its own MkRuntimeRLS and therefore its own configuration.

A function ending in 'I' is the inline variant of the function without the 'I' and is preferred in C.

[static] MkRuntimeC.Debug(?MkObjectC fmtobj = null?, ?int debug = 0?, ?String callfunc = null?, ?int lvl = 0?)

TOP

log the MkRuntimeC … → API: javamsgque.mkkernel.MkRuntimeC.Debug

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]lvla user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0)
See also
MkRuntimeC

[static] int MkRuntimeC.GetDebug()

TOP

get the MkRuntimeS::debug value … → API: javamsgque.mkkernel.MkRuntimeC.GetDebug

[static] boolean MkRuntimeC.GetIsSilent()

TOP

get the MkRuntimeS::isSilent value … → API: javamsgque.mkkernel.MkRuntimeC.GetIsSilent

[static] String MkRuntimeC.GetLogfile()

TOP

get the MkRuntimeS::logfile value … → API: javamsgque.mkkernel.MkRuntimeC.GetLogfile

Attention
the string is owned by javamkkernel -> do not free !!

[static] MkRuntimeC.SetDebug(int dbg)

TOP

set the MkRuntimeS::debug value … → API: javamsgque.mkkernel.MkRuntimeC.SetDebug

[static] MkRuntimeC.SetIsSilent(boolean silent)

TOP

set the MkRuntimeS::isSilent value … → API: javamsgque.mkkernel.MkRuntimeC.SetIsSilent

[static] MkRuntimeC.SetLogfile(String logfile)

TOP

set the MkRuntimeS::logfile value and cleanup old value … → API: javamsgque.mkkernel.MkRuntimeC.SetLogfile

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]logfilefilename, "stdout" or "stderr", default = "stderr" for NULL or ""

BINARY OBJECT

No special binary-object is used. All binary-data is available as JV byte[].


EXAMPLES

Example from server.java read a buffer-object and convert single-char-type-identifer to string.

class BUF2 implements ICallback {
  public void Callback(MqContextC ctx) {
    ctx.SendSTART();

    for (int i=0; i<3; i++) {
      MkBufferC buf = ctx.ReadU();
      ctx.SendC(Character.toString(buf.GetType1()));
      ctx.SendU(buf);
    }

    ctx.SendRETURN();
  }
}

SEE ALSO

libmkkernel, ccmkkernel, csmkkernel, javamkkernel, gomkkernel, pymkkernel, rbmkkernel, tclmkkernel, perlmkkernel, phpmkkernel

KEYWORDS

Java, unix, socket, message, msgque