Marmos
v juptune
v asn1
v lang
v ast
v Classes
v Enums
v ir
v parser
v Enums
v Structs
v core
v crypto
v keyexchange
v memory
v data
v alphabet
v buffer
v json
v builder
v parser
v Enums
v Structs
v serialise
v Structs
v Templates
v pem
v Enums
v Structs

Functions yield

1
2
3
4
5
module juptune.event.loop.async;

Result yield(
    YieldReason reason = YieldReason.other
);

Documentation

Manually yields the current fiber so that other fibers can be ran.

Since yielded fibers aren't waiting for IO to complete, the event loop thread will not sleep while there are manually yielded fibers waiting to be woken up.

This means that the event loop thread will keep spinning its CPU usage.

If you need/want to delay execution of the fiber then please use the (not currently implemented!) yieldSleepfunction instead. This will allow the event loop thread to sleep, easing CPU usage.

Reasons

When reasonis YieldReason.submitQueueIsFull, this allows the event loop to optimise its "wake up" loop so that the current fiber is only ever called when the submit queue is guarenteed to be empty. Without this reason, the fiber may be woken up only to then see that the submit queue is once again full, and immediately yields.

Params

Throws

JuptuneEventLoopError.threadWasCanceledif the thread has been canceled. This is not an actual error, but is simply used as a mechanism to encourage you to write code that can gracefully exit instead of relying on .resultAssert

Returns

A Result