MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
|
#include <Connection.h>
Public Member Functions | |
Connection () | |
~Connection () | |
void | SetConnected (bool value) |
bool | IsConnected () |
bool | IsLockedByAnother () |
bool | Lock () |
void | Unlock () |
void | ReadBlocking (bool child, u8 *buffer, u32 length) |
u32 | Read (bool child, u8 *buffer, u32 length) |
void | PeekRead (bool output, u8 *buffer, u32 index, u32 length) |
void | Write (bool child, u8 *buffer, u32 length) |
u32 | InputByteCount () |
u32 | OutputByteCount () |
void | LogAllPackets () |
void | ReportConnectionStatus (Logger::Level level, bool owned) |
A construct meant to be used by two threads as a communication channel, supporting reading and writing on both ends. Only one thread is able to access the IO of this construct at a time, allowing for thread safe operation.
|
inline |
Creates a new Connection which is not connected. Also initializes the internal mutex.
|
inline |
Deconstructs this Connection, freeing the internal mutex.
|
inline |
Number of bytes currently in the input buffer of this connection.
|
inline |
Checks whether or not this Connection is able to be used as a communication channel.
true
if this Connection is able to be written to and read from on both ends, else false
.
|
inline |
Test if the connection is currently locked by a thread other than the current thread.
FAILs with LOCK_FAILURE if the connection is locked by the current thread.
|
inline |
Locks the underlying mutex, allowing for thread-safe execution along this connection.
|
inline |
Number of bytes currently in the output buffer of this connection.
|
inline |
Reads a series of bytes from an underlying queue without blocking the calling thread. This FAILs with ARRAY_INDEX_OUT_OF_BOUNDS if reading will go over the bounds of this ThreadQueue. This does not consume any bytes from the ThreadQueue .
|
inline |
Reads from the corresponding underlying queue without blocking the calling thread.
child | This should be true if the calling thread is not the owner of this Connection. |
buffer | The location to read bytes into. |
length | The number of bytes to read from the underlying buffer. Use 0 if wanting to read as many as possible. |
|
inline |
Waits until this Connection is not busy, then reads a specified amount of bytes into a specified buffer. This method blocks the calling thread until it is able to take control of this Connection.
buffer | The buffer to write bytes read from this Connection to. |
length | The number of bytes which will be written to buffer before this method returns. |
|
inline |
Sets the connection status of this Connection, allowing or disallowing communication.
value | If true , will allow this Connection to be written to and read from. Else, will disallow these features. |
|
inline |
Unlocks the underlying mutex, allowing for another thread to lock this Connection. DO NOT call this method from a thread which does not already hold the lock!
|
inline |
Writes a series of bytes to a specified internal buffer of this Connection.
child | Selects which internal buffer to write to. If the calling object created this Connection, use true . If not, use false . |
buffer | The buffer containing the bytes to write to this Connection. |
length | The number of bytes which will be written to this Connection from buffer before this method returns. |