ALox  V. 2402 R. 0
Home ALox for C++ ALox for C# ALox for Java Download
Public Static Fields | Public Static Methods | Private Static Fields | Private Static Methods | Properties | 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 ConfigCategory = new AString( "ALIB" )
 
static readonly int MainThreadID = Thread.CurrentThread.ManagedThreadId
 
static readonly int Revision =0
 
static SmartLock StdOutputStreamsLock = new SmartLock()
 
static readonly int Version =2402
 
static VariableDecl WAIT_FOR_KEY_PRESS
 
static bool WaitForKeyPressOnTermination
 

Public Static Methods

static void Init (Configuration config)
 
static void Init (String[] args=null)
 
static bool IsWindowsOS ()
 
static bool 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 void TerminationCleanUp ()
 

Private Static Fields

static ? bool _sysInfo_HasConsoleWindow
 
static bool isInitialized = false
 
static char[] trueValuesBoolean = { 't', '1', 'y' }
 
static char[] trueValuesCase = { 's', 't', '1', 'y' }
 
static char[] trueValuesInclusion = { 'i', 't', '1', 'y' }
 

Private Static Methods

static void init ()
 

Properties

static bool HasConsoleWindow [get]
 

Member Function Documentation

◆ init()

static void init ( )
inlinestaticprivate

Used by Init functions.

◆ Init() [1/2]

static void Init ( Configuration  config)
inlinestatic

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() [2/2]

static void Init ( String[]  args = null)
inlinestatic

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 implementation, the only configuration variable read with this method is WAIT_FOR_KEY_PRESS.
Parameters
argsParameters taken from standard C# method main() (the list of command line arguments). Defaults to null.

◆ IsWindowsOS()

static bool IsWindowsOS ( )
inlinestatic

Detects if this is running on Windows OS.

Returns
true if the calling process is running on Windows

◆ ReadBoolean()

static bool ReadBoolean ( Substring  src)
inlinestatic

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)
inlinestatic

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)
inlinestatic

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)
inlinestatic

Suspends the current thread by calling Thread.Sleep(). Provided for compatibility with other platform versions of ALib. Variants of this method are SleepMillis, SleepMicros and SleepNanos.

Parameters
ticksSleep time in Ticks.

◆ SleepMicros()

static void SleepMicros ( long  microsecs)
inlinestatic

Suspends the current thread by calling Thread.Sleep(). Provided for compatibility with other platform versions of ALib. Variants of this method are Sleep, SleepMillis and SleepNanos.

Parameters
microsecsSleep time in microseconds.

◆ SleepMillis()

static void SleepMillis ( int  millisecs)
inlinestatic

Suspends the current thread by calling Thread.Sleep(). Provided for compatibility with other platform versions of ALib. Variants of this method are Sleep, SleepMicros and SleepNanos.

Parameters
millisecsSleep time in milliseconds.

◆ SleepNanos()

static void SleepNanos ( long  nanosecs)
inlinestatic

Suspends the current thread by calling Thread.Sleep(). Provided for compatibility with other platform versions of ALib. Variants of this method are Sleep, SleepMillis and SleepMicros.

Parameters
nanosecsSleep time in microseconds.

◆ TerminationCleanUp()

static void TerminationCleanUp ( )
inlinestatic

Got nothing to do in C#.

Member Data Documentation

◆ _sysInfo_HasConsoleWindow

? bool _sysInfo_HasConsoleWindow
staticprivate

Internal flag used to by property HasConsoleWindow

◆ Config

Configuration Config =null
static

The configuration used by ALox. 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 ALox library.
The option to use an exclusive one may be used to store ALox 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 ConfigCategory.

◆ ConfigCategory

AString ConfigCategory = new AString( "ALIB" )
static

The name of the configuration category of configuration variables used by the AWorx library.
Defaults to "ALIB".
6 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

bool isInitialized = false
staticprivate

State of initialization, used to avoid double initialization.

◆ MainThreadID

readonly int MainThreadID = Thread.CurrentThread.ManagedThreadId
static

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

◆ Revision

readonly int Revision =0
static

The revision number of this release. Each ALib Version is initially released as revision 0. Pure bug-fix releases that do not change the interface of ALib 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. Console.WriteLine, 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

readonly int Version =2402
static

The ALib version. The versioning 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.

◆ WAIT_FOR_KEY_PRESS

VariableDecl WAIT_FOR_KEY_PRESS
static
Initial value:
= new VariableDecl(
ALIB.ConfigCategory, null, "WAIT_FOR_KEY_PRESS",
"",
'\0', null, Variable.FormatHint.None,
"If true, the process waits for a key stroke on termination. If empty, under Windows \n"
+ "behavior is detected, under other OSes, defaults to false." )

Configuration variable declaration.

◆ WaitForKeyPressOnTermination

bool WaitForKeyPressOnTermination
static

If true, within TerminationCleanUp, it is waited for a key press in the console window.
By default, this flag is enabled when debugging a console application under Visual Studio.
This default behavior can be overruled by setting configuration variable ALIB_WAIT_FOR_KEY_PRESS.
In addition, this public flag may be modified at runtime.

Property Documentation

◆ HasConsoleWindow

bool HasConsoleWindow
staticget

Determines if a console is attached to this process


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