StgSharp.Common
Lock-free, fixed-capacity stack implemented on top of an array using atomic index
operations. - No linked list; only array slots - Uses CAS on a shared top index to
reserve/release slots - Per-slot state flag to safely publish/consume values under races
Best-effort snapshot for enumeration; not strongly consistent under concurrent
mutations.
Determines whether the contains the
specified key.
The value to locate in the .
true if the contains an element with
the specified key; otherwise, false.
Determines whether the contains the
specified key.
The value to locate in the .
true if the contains an element with
the specified key; otherwise, false.
Cache hash result for obj with counts.
Part of a collection. This contains a direct reference to _origin collection, so all
change to _origin collection will be reflected in this object.
Initializes a new instance of the RandomAccessStack class that is empty and has the
default initial capacity.
Initializes a new instance of the RandomAccessStack class that is empty and has the
specified initial capacity.
Gets or sets the element at the specified index in the stack (0 = bottom, Count-1 =
top).
Gets the number of elements contained in the stack.
Removes all objects from the stack.
Returns an enumerator that iterates through the stack from top to bottom. Throws if
the stack is modified during iteration.
Returns the object at the top of the stack without removing it.
Removes and returns the object at the top of the stack.
Adds an item to the top of the stack.
CustomizeInit an instance of OpenGL program, This method should be called before any
other World api.
Version of current World platform. Main version represent in hundred's digit, and sub
version represent in ten's digit.
Write a log message to log file, and mark the _level of this message.
A string contains information of how current evironment runs.
The severity of current message.
A class attempt to reduce cost of boxing, though still a bit slower than direct access to
_origin value type instance.
Type of instance to be boxed.
A class contains a sets of methods to serialize several types
An independent storage area, used as the only folder type in root folder. Contains several
files reference as virtual disc. Data is actually stored in s in certain RAID mode.
当几何体调用了过多的CalcVec方法时,产生UnusedVertexException异常
Plain geometry only contains straight sides.
Calculate movement to center
CurrentPipeline time tick
A square
Get all uniform related to this .
Shader program requires this camera.
ContextName of all related uniforms. If you fallow form from
A two dimension vector defined by two elements. Vec2 in World are default used as colum
vector.
Orthogonalize two s, let their length be 1 and perpendicular to
each other.
Length of the matrix in columns.
Length of the matrix in rows.
Reurns the value of ArcSin(x)
The sine value of the angle
Get the value of E ^ x;
Returns the value of ln(x).
calculate the value of x^y
Returns the value of x^y
returns a random float number between 0 and 1.
Generates a random seed in int value.
Interface of all kinds OpenGL BufferHandle objects
Get the only handle to one of the Object instance
Bind a BufferHandle instance to OpenGL
Index of handle of the object in this instance to be bind
Function handler to load an opengl function by searching its _label.
the _label of the Opengl function
An Intptr value representing the pointer to the function
Hash code of time pixels updated last time.
A collection of a sets of OpenGL textures. The collection can automatically select one of
the texture with minimum costs to upgrade pixels to BufferHandle. Usually is used for loading, but not for
target of .
A collection of handle to Element BufferHandle Object in OpenglFunc. Each value indexed from instance of this class this is the only handle to
one Element BufferHandle Object.
Bind the frame BufferHandle object with _label frame BufferHandle to the frame
BufferHandle target specified by target. will
be set as default target.
Index of object to be binded in handle set
Bind the frame BufferHandle object with _label frame BufferHandle to the frame
BufferHandle target specified by target. Target of this frame BufferHandle should be
set manually.
The frame BufferHandle target of the binding operation.
Index of object to be binded in handle set
Load an to certain texture.
Set _data to current vertex BufferHandle object
Type of bufferData
Index to find certain VBO in this instance
Data to write in
How OpenGL use these _data, defined by
Set _data to current vertex BufferHandle object
Type of bufferData
Index to find certain VBO in this instance
Data to write in
How OpenGL use these _data, defined by
Set _data to current vertex BufferHandle object
Type of bufferData
Index to find certain VBO in this instance
A of _data to write in
How OpenGL use these _data, defined by
Set data to current vertex BufferHandle object
Type of bufferData
Index to find certain VBO in this instance
A of data to write in
How OpenGL use these data, defined by
Set _data to current vertex BufferHandle object
Type of bufferData
Index to find certain VBO in this instance
A array of _data to write in
How OpenGL use these _data, defined by
Get the function pointer of given OpenGL api _label
ContextName of the OpenGL api
The funtion pointer of the api in stream of
Load all supported OpenGL APIs and bind them to given .
The handle to current OpenGL viewPortDisplay
Create a set of .
Amount of EBO to be created.
Create a sets of
Amount of textures to be created.
Create a set of .
Amount of VAO to be created.
Create a set of .
Amount of Object to be created.
Initialize an opengl context and load all opengl functions.
Initialize an OpenGl viewPortDisplay if current form has not been binded to any
viewPortDisplay. and set the viewPortDisplay binded to current form as current OpenGL
viewPortDisplay.
Something goes wrong and World fails in creating a new OpenGL viewPortDisplay.
Create an instance of program
New instance of instance.
OpenGL numeric type. An IEEE-754 floating-point value, clamped to the range [0,1].
OpenGL numeric type. An IEEE-754 double precision floating-point value, clamped to the
range [0,1].
Attach one shader code to a shader program.
Shader program to attach
Index of shader code in current shader code set.
CustomizeInit a program with no shader attached.
Get a uniform form current shader, the value type of the uniform should be provided.
ContextName of the Uniform in shader code
Get a uniform form current shader, the value type of the uniform should be provided.
ContextName of the Uniform in shader code
Get a uniform form current shader, the value type of the uniform should be provided.
ContextName of the Uniform in shader code
Get a uniform form current shader, the value type of the uniform should be provided.
ContextName of the Uniform in shader code
Link the shader to current viewPortDisplay.
Let the current viewPortDisplay use this shader.
Set the Size limit of current form
Minimum width of current form
Minimum height of current form
Maximum width of current form
Maximum height of current form
Get (TView is ) uniform from a shader.
This uniform will be used as projection matrix of this camera. Additionally, for
multi- shader rendering, each shader requires a uniform, so do not ignore return
value of this method.
Shader using this camera
ContextName of projection camera named in shader
(TView is ) representing projection
matrix in shader program.
Marking the start of current render operations, and set this renser context as
current.
Marking the end of current render operations, and release the binding of this renser
context to current, making it available for another thread as current.
Provide a lock for managing concurrent access to a buffer that can be expanded and use a
common two-pase-copy expanding mechanism.
An individual thread doing nothing, and its always returns false.
A single-consumer bell/signal primitive.
Producers can call multiple times to publish signals. The bell
keeps a pending count of not-yet-consumed signals. The consumer uses or to consume
signals. When a producer increments the pending count from 0 to 1, the
internal event is set to wake the consumer. Consuming via
or clears the entire pending count
(aggregate consumption). If new signals arrive while resetting, the event is set again to
avoid missed signals. Ownership: only the specified owner can call
the consumer APIs.
Initializes a new instance of .
The unique consumer identity; subsequent calls to Wait/TryWait must pass the same
reference.
Spin count passed to the underlying .
Thrown if is null.
Disposes the bell, sets the event to wake any waiting consumer, and releases
resources.
Publishes a signal by incrementing the not-yet-consumed count and returns the current
pending count.
If the pending count transitions from 0 to 1, the event is set to wake the consumer.
The current pending count including this call.
Attempts to consume any pending signals without blocking.
The consumer object; must be the same reference provided at construction.
true if a signal was available (pending or event set); otherwise false
.
Thrown if is not the owner.
Blocks until a signal is available, then consumes all pending signals.
The consumer object; must be the same reference provided at construction.
A token to cancel the wait.
Thrown if is not the owner.
A counting semaphore with adjustable maximum capacity at runtime. Implemented using one or
more ManualResetEventSlim (MRES) gates and atomic counters to avoid kernel semaphore
overhead while supporting high-frequency Release/Wait patterns. Notes: - This is a
counting primitive (not a barrier). Permits accumulate up to . -
Reducing does not revoke already issued permits; it only clamps
future releases. - Striped MRES can reduce contention in highly parallel waits.
Current number of available permits.
Logical maximum number of permits. Can be changed at runtime.
Release a single permit if under . Returns the previous
count.
Release multiple permits (capped by ). Returns the previous
count.
Try to take a permit without blocking. Returns true if acquired.
Block until a permit is available, then consume one.
Block until a permit is available or canceled, then consume one.
Abstraction for a wide SIMD register or equivalent packed numeric storage. Provides raw
reference access, broadcast initialization and element level access. Typical
implementations map to 128/256/512-bit hardware registers or software emulated blocks.
Gets a reference to the first element of the register reinterpreted as type .
Unmanaged numeric element type implementing .
Writable reference to element 0 (lowest lane / lowest bits).
Intended for treating the register as a contiguous block of elements. The returned reference
must remain valid for the lifetime of the register and be identical to with index 0. Caller must choose a type layout compatible with the
actual register representation.
Fills all elements (lanes) of the register with the provided scalar .
Unmanaged numeric element type implementing .
Scalar value to replicate to every element.
Should map to a single broadcast/shuffle instruction where possible. After completion all
lanes read back the same value.
Gets a writable reference to the element at the specified .
Unmanaged numeric element type implementing .
Zero-based lane index (range defined by implementation).
Writable reference to the lane.
Enables scalar lane edits without unpacking the entire register. Implementations may omit
bounds checks for performance. Caller is responsible for passing a valid index.
Buffer for SSE targeted matrix panel, size of a panel is 4x4 elements, and no smaller than
16 bytes.
Type of matrix element.
Buffer for AVX targeted matrix panel, size of a panel is 4x4 elements, and no smaller than
16 bytes.
Type of matrix element.
Buffer for AVX512 targeted matrix panel, size of a panel is 4x4 elements, and no smaller
than 16 bytes.
Type of matrix element.
Try to allocate a new 16MB block when all buckets are empty
Output handle to the allocated Entry
True if allocation succeeded
Helper method for allocation - converts BucketNode to Entry
BucketNode structure - specialized node for bucket linked lists Stored in main
allocation area (user-overwritable region)
Free allocated memory block and perform adjacent block merging
Handle to the allocated memory block
Determine segment index based on size and originLevel
Check if two Entries are adjacent in memory
Used in Free operations, efficiently remove from buckets and merge adjacent blocks.
Current Entry will serve as the final merged block. The Merge will be in lazy
strategy, any fail in acquiring spin lock will end a merging process.
Remove node from position linked list
Entry structure - streamlined version (only position and state information) Stored in
external SLAB
Creates a new SLAB allocator instance with the specified configuration.
Initial number of objects that can be allocated.
Memory layout strategy for the SLAB allocator.
Whether to enable concurrent access support.
A new SLAB allocator instance.
Thrown when an invalid layout is specified.
Thrown when requesting unsupported configurations.
Important Threading Considerations: While SLAB
/// allocators themselves may be designed for single-threaded use, allocated objects
are /// frequently shared across multiple threads in real-world applications. Due to
the /// special implementation of expandable concurrent sequential SLAB allocators,
they rely /// on internal expansion locks to ensure that memory buffer expansions
(which involve /// copying the entire buffer to a new location) do not occur while
other threads are /// reading from allocated regions.
Sequential Layout Limitations: ///
Sequential layout SLAB
allocators cannot provide a single-threaded /// version because:- They use contiguous memory /// layout that requires
buffer expansion when capacity is exceeded
///
- Buffer expansion involves copying all ///
existing data to a new memory location
- ///
Without proper synchronization, concurrent access to allocated objects during ///
expansion would cause memory corruption
- The
/// expansion lock mechanism is essential even if allocation itself is single- ///
threaded
Chunked Layout:
///
Chunked layout allocators can optionally provide single-threaded
/// versions since they don't require buffer expansion and copying. Each chunk is
/// allocated independently, avoiding the memory relocation issues present in
sequential /// layouts.
CustomizeInit this form and render it on screen, and respond with operation
Height of this form, represent in
Width of this form, represent in
Width of this form, represent in
Set the Size limit of current form
Minimum Size of current form. In form of a of (width,height)
Maximum Size of current form. In form of a of (width,height)
Set the Size limit of current form
Minimum width of current form
Minimum height of current form
Maximum width of current form
Maximum height of current form
ViewBase is the base type for all view types, providing context binding and control
element binding. A complete view should contain one complete , , and , which provide
layout descriptions of control elements, user responses, and rendering implementations in
the view. Data between instances of , , and is shared through .
Get the status of a certain key on the keyboard.
representing if a key is pressed or released.
ViewDesigner provides descriptions of various controls in the view, binds the
controls to specific user actions and behaviors, and describes the layout and
interactions of each control.
Reset pipeline has risk, this operation is a direct operation to port in current node, the
port on the other node cannot get the change.
Only the following occasions of calling are valid: 1. no bp is
running or the only bp is quitting. 2. calling from the main thread or a
thread the current bp is running on.
A sets of complex logic designed for running in multi threads environment. Warning: do not
run a instance in multi threads more than once.
TimeSpanProvider: uses a bound TimeSequence and TimeSourceProviderBase to publish span
ticks. Each OnSpanTick advances the sequence; when sequence ends provider unsubscribes.
True if there is at least one unconsumed span tick (PendingSpanCount > 0).
Number of span ticks not yet consumed by Wait ( > 0 means last tick not waited).
Tick passed since binded time source.
True if the span provider is working. False if time is over (the sequence ended).
Efficient adaptive backoff strategy that dynamically selects optimal backoff methods based on
system load and success rate
Gets the currently used backoff method (for debugging/monitoring)
Gets the globally considered optimal backoff method
Creates a new adaptive backoff strategy instance
Gets global statistics for the specified strategy (for monitoring)
Called after CAS failure, performs backoff and may switch strategies
Called after CAS success, resets state
Evaluates and updates the global optimal strategy
Fast pseudo-random number generator (LCG)
Performs the actual backoff operation
Checks whether global strategy evaluation should be performed
Determines whether strategy should be switched
Switches to the currently considered optimal strategy