public class MsgDispatcherCore extends LogMessageBase
Modifier and Type | Class and Description |
---|---|
static class |
MsgDispatcherCore.Entry
Stores all data of a message if the message is queued here.
|
protected static class |
MsgDispatcherCore.Output
This class contains all infomations for a output.
|
protected static class |
MsgDispatcherCore.TestCnt
This class contains some test-counts for debugging.
|
Modifier and Type | Field and Description |
---|---|
protected int |
actNrofListIdents
List of idents, its current length.
|
(package private) int |
ctLostMessages |
protected MsgDispatcherCore.Entry |
entryMsgBufferOverflow |
(package private) ConcurrentLinkedQueue<MsgDispatcherCore.Entry> |
freeOrders
List of entries for messages to use.
|
(package private) long |
idThreadForDispatching |
protected int[] |
listBitDst
List of destination bits for the idents.
|
protected int[] |
listIdents
List of idents, a array with lengthListIdents elements.
|
(package private) ConcurrentLinkedQueue<MsgDispatcherCore.Entry> |
listOrders
List of messages to process in the dispatcher thread.
|
static int |
mAdd
Used for argument mode from
#setOutputRange(int, int, int, int, int) to add an output. |
static int |
mConsole
Mask for dispatch the message to console directly in the calling thread.
|
static int |
mConsoleQueued
queued Console output, it is a fix part of the Message dispatcher.
|
static int |
mDispatchBits
Only this bits are used to indicate the destination via some Bits
|
static int |
mDispatchInCallingThread
If this bit is set in the bitmask for dispatching, the dispatching should only be done
in the calling thread.
|
static int |
mDispatchInDispatcherThread
If this bit is set in the bitmask for dispatching, the dispatching should be done
in the dispatcher Thread.
|
int |
mDstMixedOutputs
Calculated mask of bits which are able to mix.
|
int |
mDstOneOutput
Calculated mask of bits which are one index.
|
static int |
mRemove
Used for argument mode from
#setOutputRange(int, int, int, int, int) to remove an output. |
static int |
mSet
Used for argument mode from
#setOutputRange(int, int, int, int, int) to set an output. |
protected MsgText_ifc |
msgText
Converter from the ident number to a text.
|
protected int |
nrofMixedOutputs
Number of Bits in
mDispatchWithBits , it is the number of destinations dispatched via bit mask. |
protected MsgDispatcherCore.Output[] |
outputs
up to 30 destinations for output.
|
protected java.lang.Runnable |
runNoEntryMessage |
(package private) MsgDispatcherCore.TestCnt |
testCnt |
static int |
version
version, history and license.
|
nLogLevel
dateFormat, debug, error, fineDebug, fineInfo, info, minSecondsFormat, mNeverOutputToDisplay, mReportLevel, sVersion, warning
Constructor and Description |
---|
MsgDispatcherCore(int maxQueue,
int nrofMixedOutputs,
java.lang.Runnable runNoEntryMessage)
Initializes the instance.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Appendable |
append(char c)
This is more formally, only one char is nonsense for the MsgDispatcher.
|
java.lang.Appendable |
append(java.lang.CharSequence csq)
TODO yet message nr 0 is created, get the message from the start text...
|
java.lang.Appendable |
append(java.lang.CharSequence csq,
int start,
int end) |
void |
close()
This routine may be overridden by the inherited class (usual
MsgDispatcher to support closing. |
protected int |
dispatchMsg(int dstBits,
boolean bDispatchInDispatcherThread,
boolean bDispatchAlways,
int identNumber,
OS_TimeStamp creationTime,
java.lang.CharSequence text,
Va_list args)
Dispatches a message.
|
int |
dispatchQueuedMsg()
Dispatches all messages, which are stored in the queue.
|
void |
flush()
This routine may be overridden by the inherited class (usual
MsgDispatcher to support flushing
all queued messages. |
boolean |
isOnline()
Checks whether the message output is available.
|
int |
searchDispatchBits(int ident)
Searches and returns the bits where a message is dispatch to.
|
boolean |
sendMsg(int identNumber,
java.lang.CharSequence text,
java.lang.Object... args)
Sends a message.
|
boolean |
sendMsgTime(int identNumber,
OS_TimeStamp creationTime,
java.lang.CharSequence text,
java.lang.Object... args)
Sends a message.
|
boolean |
sendMsgVaList(int identNumber,
OS_TimeStamp creationTime,
java.lang.CharSequence text,
Va_list args)
Sends a message.
|
void |
setIdThreadForMsgDispatching(long idThread)
Sets the capability that messages which are create in the dispatcher thread are output immediately
though the output channel should be used in the dispatcher thread.
|
void |
setMsgTextConverter(MsgText_ifc converter) |
void |
tickAndFlushOrClose()
Dispatches the queues messages, after them calls
LogMessage.flush() for all queued outputs. |
flushReport, getReportLevel, getReportLevelFromIdent, report, report, reportln, reportln, setReportLevel, setReportLevelToIdent, writeError, writeError, writeInfo, writeInfoln, writeWarning
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
msgSec, timeCurr, timeMsg
public static final int version
setIdThreadForMsgDispatching(long)
tickAndFlushOrClose()
should be part of the core.
MsgDispatcher
.
MsgDispatcherCore.Output.bUseText
stores whether the output channel uses the text.
The #dispatchMsg(int, boolean, int, OS_TimeStamp, String, Va_list)
gets a text from configuration
only if it is need.
#sendMsgVaList(int, OS_TimeStamp, String, Va_list)
counts whether a message can't be queued.
it is used to output a 'lostmessage' message in dispatchQueuedMsg()
.
setMsgTextConverter(MsgText_ifc)
. It provides a possibility to work with a
translation from ident numbers to text with an extra module, it is optional.
public static final int mDispatchInDispatcherThread
public static final int mDispatchInCallingThread
mDispatchInDispatcherThread
is set, if there is more as one destination.public static final int mDispatchBits
protected final int nrofMixedOutputs
mDispatchWithBits
, it is the number of destinations dispatched via bit mask.public final int mDstMixedOutputs
public final int mDstOneOutput
public static final int mConsole
public static final int mConsoleQueued
public static final int mAdd
#setOutputRange(int, int, int, int, int)
to add an output.
The other set outputs aren't change.public static final int mSet
#setOutputRange(int, int, int, int, int)
to set an output.
Outputs before are removed.public static final int mRemove
#setOutputRange(int, int, int, int, int)
to remove an output.
All other outputs aren't change.long idThreadForDispatching
final MsgDispatcherCore.TestCnt testCnt
final ConcurrentLinkedQueue<MsgDispatcherCore.Entry> listOrders
final ConcurrentLinkedQueue<MsgDispatcherCore.Entry> freeOrders
protected final MsgDispatcherCore.Entry entryMsgBufferOverflow
protected int actNrofListIdents
protected int[] listIdents
protected int[] listBitDst
protected MsgDispatcherCore.Output[] outputs
protected MsgText_ifc msgText
setMsgTextConverter(MsgText_ifc)
protected final java.lang.Runnable runNoEntryMessage
int ctLostMessages
MsgDispatcherCore(int maxQueue, int nrofMixedOutputs, java.lang.Runnable runNoEntryMessage)
maxQueue
- The static limited maximal size of the queue to store messages from user threads
to dispatch in the dispatcher thread. If you call the dispatching in dispatcher thread
cyclicly in 100-ms-steps, and you have worst case no more as 200 messages in this time,
200 is okay.nrofMixedOutputs
- public void setIdThreadForMsgDispatching(long idThread)
tickAndFlushOrClose()
is started
after continue the startup routine but in the same main thread.
The startup messages should be seen without delay, especially on problems on startup.
idThread
- It should be that thread id of the Thread which runs tickAndFlushOrClose()
.public final void setMsgTextConverter(MsgText_ifc converter)
public final int searchDispatchBits(int ident)
ident
- The message identificatormDstMixedOutputs
etc.public final boolean sendMsg(int identNumber, java.lang.CharSequence text, java.lang.Object... args)
identNumber
- text
- The text representation of the message, format string, see java.lang.String.format(..).args
- see interfacepublic final boolean sendMsgTime(int identNumber, OS_TimeStamp creationTime, java.lang.CharSequence text, java.lang.Object... args)
identNumber
- text
- The text representation of the message, format string, see java.lang.String.format(..).args
- see interfacecreationTime
- absolute time stamp. @Java2C=perValue.public final boolean sendMsgVaList(int identNumber, OS_TimeStamp creationTime, java.lang.CharSequence text, Va_list args)
identNumber
- creationTime
- text
- The identifier text @pjava2c=zeroTermString.typeArgs
- Type chars, ZCBSIJFD for boolean, char, byte, short, int, long, float double.args
- see interfacepublic java.lang.Appendable append(java.lang.CharSequence csq) throws java.io.IOException
LogMessage
with Appendable.java.io.IOException
public java.lang.Appendable append(java.lang.CharSequence csq, int start, int end) throws java.io.IOException
java.io.IOException
public java.lang.Appendable append(char c) throws java.io.IOException
java.io.IOException
public final boolean isOnline()
LogMessage
public void close()
MsgDispatcher
to support closing.LogMessage.close()
public void flush()
MsgDispatcher
to support flushing
all queued messages.LogMessage.close()
public final void tickAndFlushOrClose()
LogMessage.flush()
for all queued outputs.
This method can be called in any user thread cyclically.
As opposite the DispatcherThread
can be instantiate and DispatcherThread#start()
.
That thread calls only this routine in its cycle.public final int dispatchQueuedMsg()
tickAndFlushOrClose()
and in @ flush()
and link #close()}.protected final int dispatchMsg(int dstBits, boolean bDispatchInDispatcherThread, boolean bDispatchAlways, int identNumber, OS_TimeStamp creationTime, java.lang.CharSequence text, Va_list args)
dstBits
- Destination identificator. If the bit mDispatchInDispatcherThread
is set,
the dispatching should be done only for a destination if the destination is valid
for the dispatcher thread.
Elsewhere if the bit is 0, the dispatching should be done only for a destination
if the destination is valid for the calling thread.bDispatchInDispatcherThread
- true if this method is called in dispatcher thread,
false if called in calling thread. This param is compared with MsgDispatcherCore.Output.dstInDispatcherThread
,
only if it is equal with them, the message is output.bDispatchAlways
- true then the output is used both in calling and in dispatcher thread.
This boolean should be set only if the calling thread is the same as the dispatcher thread
and the message should dispatch in the messag creation thread therefore.identNumber
- identification of the message.creationTime
- text
- The identifier text @pjava2c=zeroTermString.args
- @pjava2c=nonPersistent.