ALox  V. 2402 R. 0
Home ALox for C++ ALox for C# ALox for Java Download
Public Static Fields | Public Static Methods | Protected Static Fields | Private Static Fields | Protected Static Methods | List of all members
ALIB Class Reference
Collaboration diagram for ALIB:
[legend]

Class Description


This class is a 100% static placeholder for global methods and fields of ALib. Among the things implemented here are:

Public Static Fields

static Configuration config =null
 
static AString configCategoryName = new AString( "ALIB" )
 
static Long mainThreadID = Thread.currentThread().threadId()
 
static final int revision =0
 
static SmartLock stdOutputStreamsLock = new SmartLock()
 
static final int version =2402
 

Public Static Methods

static void init (Configuration config)
 
synchronized static void init (String[] args)
 
static boolean readBoolean (Substring src)
 
static Case readCase (Substring src)
 
static Inclusion readInclusion (Substring src)
 
static void sleep (Ticks ticks)
 
static void sleepMicros (long microsecs)
 
static void sleepMillis (int millisecs)
 
static void sleepNanos (long nanosecs)
 
static boolean sysInfo_IsAndroid ()
 
static void terminationCleanUp ()
 

Protected Static Fields

static boolean isInitialized = false
 

Private Static Fields

static char[] trueValuesBoolean = { 't', '1', 'y' }
 
static char[] trueValuesCase = { 's', 't', '1', 'y' }
 
static char[] trueValuesInclusion = { 'i', 't', '1', 'y' }
 

Protected Static Methods

static void init ()
 

Member Function Documentation

◆ init() [1/3]

static void init ( )
staticprotected

Used by init functions.

◆ init() [2/3]

static void init ( Configuration  config)
static

Variant of method init, accepting a configuration. This will be stored in field config and used for loading and storing ALib variables.

Parameters
configThe configuration object to use with ALib variables.

◆ init() [3/3]

synchronized static void init ( String[]  args)
static

This method must be called prior to using ALib, e.g. at the beginning of the main() method of an application. It is OK, to call this method more than once, which allows independent code blocks (e.g. libraries) to bootstrap ALIB independently. However, only the first invocation is effective

The very first invocation should not be interrupted by a parallel invocation of a second thread. Consequently, with more complex applications it is recommended to explicitly invoke this method once when the software is bootstrapped.

If command line parameters should be used for configuring ALox, then the very first call to this method has to provide the argc and argv parameters. Subsequent calls to this method with different parameters do not change the setup.

If other, custom configuration data sources should be used already with this method use overloaded method ALIB.init(Configuration).

Note
In the current Java implementation of ALib, no configuration variables are read.
Parameters
argsParameters taken from standard Java method main() (the list of command line arguments). Accepts null to ignore command line parameters.

◆ readBoolean()

static boolean readBoolean ( Substring  src)
static

Interprets given src as a boolean value. enums.Inclusion. If the case insensitive comparison of the first non-whitespace characters of the string with with values "t", "1", "y", "on", "ok" matches, true is returned. Otherwise, including the case that src is 'nulled', false is returned.

Parameters
srcThe string to 'parse'.
Returns
The Case value read.

◆ readCase()

static Case readCase ( Substring  src)
static

Interprets given src as a value of enum type enums.Case. If the case insensitive comparison of the first non-whitespace characters of the string with values "s", "y", "t", "1" matches, Case.SENSITIVE is returned. Otherwise, including the case that src is 'nulled', Case.IGNORE is returned.

Parameters
srcThe string to 'parse'.
Returns
The Case value read.

◆ readInclusion()

static Inclusion readInclusion ( Substring  src)
static

Interprets given src as a value of enum type enums.Inclusion. If the case insensitive comparison of the first non-whitespace characters of the string with values "i", "y", "t", "1" matches, Inclusion.INCLUDE is returned. Otherwise, including the case that src is 'nulled', Inclusion.EXCLUDE is returned.

Parameters
srcThe string to 'parse'.
Returns
The Inclusion value read.

◆ sleep()

static void sleep ( Ticks  ticks)
static

Suspends the current thread for the given number of milliseconds. Variants of this method are sleepMillis, sleepMicros and sleepNanos.

Parameters
ticksSleep time in Ticks.

◆ sleepMicros()

static void sleepMicros ( long  microsecs)
static

Suspends the current thread for the given number of microseconds. Variants of this method are sleep, sleepMillis and sleepNanos.

Parameters
microsecsSleep time in microseconds.

◆ sleepMillis()

static void sleepMillis ( int  millisecs)
static

Suspends the current thread for the given number of milliseconds. Variants of this method are sleep, sleepMicros and sleepNanos.

Parameters
millisecsSleep time in milliseconds.

◆ sleepNanos()

static void sleepNanos ( long  nanosecs)
static

Suspends the current thread for the given number of nanoseconds. Variants of this method are sleep, sleepMillis and sleepNanos.

Parameters
nanosecsSleep time in nanoseconds.

◆ sysInfo_IsAndroid()

static boolean sysInfo_IsAndroid ( )
static

Detects if this is an Android application. This, in the current implementation is done by looking for class

Returns
true if the calling process is running on Android

◆ terminationCleanUp()

static void terminationCleanUp ( )
static

Got nothing to do in Java.

Member Data Documentation

◆ config

Configuration config =null
static

The configuration used by ALib. This is received or created with overloaded init methods. It might be shared with other libraries or can be an instance explicitly dedicated to the ALib library.
The option to use an exclusive one may be used to store ALib configuration variables in different configuration files, e.g. to reduce "clutter" of an applications' then "main" configuration file.
Changes should only be made at very initial, single threaded bootstrap code, with the invocation of the according method init(Configuration).

See also
Field configCategoryName.

◆ configCategoryName

AString configCategoryName = new AString( "ALIB" )
static

The name of the configuration category of configuration variables used by the AWorx library.
Defaults to "ALIB".
This value can be changed to avoid conflicts between applications (especially in respect to environment variable settings). Changes should be placed at very initial bootstrap code, before the invocation of init.

◆ isInitialized

boolean isInitialized = false
staticprotected

State of initialization, used to avoid double initialization.

◆ mainThreadID

Long mainThreadID = Thread.currentThread().threadId()
static

The ID of the thread that initialized this static field. This is supposedly thread "main".

◆ revision

final int revision =0
static

The revision number of this release. Each ALib version is initially released as revision 0. Pure maintenance releases that do not change the interface of ALox are holding the same version but an increased number in this field.

◆ stdOutputStreamsLock

SmartLock stdOutputStreamsLock = new SmartLock()
static

This is a smart mutex that allows to lock an applications' standard output streams.

In multi-threaded processes, to protect the output streams from concurrent access, this smart lock might be used by any entity that writes data to the streams. Before it can be used (acquired and released), it is needed to register with the object using SmartLock.addAcquirer. This has to be done once per thread that aims to write to the stream. Then, prior to writing, this object has to be acquired and after writing released.

Because often, the standard output stream and standard error stream are identical, ALib provides one single lock for both, to protect also against interwoven standard output and error information.

If the 'entity' that is registering is not of type ThreadLock it is allowed to provide null in the parameter of method AddAcquirer. In this case, the process of adding and removing acquirers is not performed in a thread safe way. Therefore it is advised to register so called anonymous (null) acquirers only at bootstrap time, when no parallel threads were started, yet.

If an application is deemed to always write to the standard output streams from within multiple threads, an alternative to registering each writing entity, is to invoke AddAcquirer just two times in a row with null at the start of a process and then never do this again (and never de-register). This way, no thread needs to register/deregister but threads may still Acquire and Release the lock without being registered. In other words, once a smart lock is enabled, subsequent registrations are just used to count and identify the de-registration.

Note
The advantage of the SmartLock is that if only one 'entity' registered, no system mutexes will be used with Acquire and Release, hence there is a performance gain. Such gain is not noticeable for the 'slow' terminal console output, but it is for fast, buffered output streams.
Logging library ALox, which is built on ALib, will register whenever a Logger is used that writes to the standard output stream. Hence, applications that in parallel use, e.g. 'std.cout', should register at bootstrap and acquire this instance prior to writing. This way, log output and other application output is not mixed, but separated in different Lines.

◆ trueValuesBoolean

char [] trueValuesBoolean = { 't', '1', 'y' }
staticprivate

Strings used to identify a boolean value from a string representation

◆ trueValuesCase

char [] trueValuesCase = { 's', 't', '1', 'y' }
staticprivate

Strings used to identify an enum Case from a string representation

◆ trueValuesInclusion

char [] trueValuesInclusion = { 'i', 't', '1', 'y' }
staticprivate

Strings used to identify an enum Inclusion from a string representation

◆ version

final int version =2402
static

The version of ALib. The version number follows the scheme YYMM (2-digit year, 2-digit month) of the initial release date. Besides this version number, field revision indicates if this is a revised version of a former release.


The documentation for this class was generated from the following file: