Package software.amazon.awssdk.crt.io
Class EventLoopGroup
- java.lang.Object
-
- software.amazon.awssdk.crt.CrtResource
-
- software.amazon.awssdk.crt.io.EventLoopGroup
-
- All Implemented Interfaces:
AutoCloseable
public final class EventLoopGroup extends CrtResource
This class wraps the aws_event_loop_group from aws-c-io to provide access to an event loop for the MQTT protocol stack in the AWS Common Runtime.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class software.amazon.awssdk.crt.CrtResource
CrtResource.ResourceInstance
-
-
Constructor Summary
Constructors Constructor Description EventLoopGroup(int numThreads)
Creates a new event loop group for the I/O subsystem to use to run non-blocking I/O requestsEventLoopGroup(int cpuGroup, int numThreads)
Creates a new event loop group for the I/O subsystem to use to run non-blocking I/O requests.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
canReleaseReferencesImmediately()
Determines whether a resource releases its dependencies at the same time the native handle is released or if it waits.static void
closeStaticDefault()
Closes the static default event loop group, if it exists.CompletableFuture<Void>
getShutdownCompleteFuture()
protected void
releaseNativeHandle()
Stops the event loop group's tasks and frees all resources associated with the the group.static void
setStaticDefaultNumThreads(int numThreads)
Sets the number of threads for the static default event loop group, should it ever be created.-
Methods inherited from class software.amazon.awssdk.crt.CrtResource
acquireNativeHandle, addRef, addReferenceTo, close, collectNativeResource, collectNativeResources, decRef, getNativeHandle, getResourceLogDescription, isNull, logNativeResources, releaseReferences, removeReferenceTo, setDescription, swapReferenceTo, waitForNoResources
-
-
-
-
Constructor Detail
-
EventLoopGroup
public EventLoopGroup(int numThreads) throws CrtRuntimeException
Creates a new event loop group for the I/O subsystem to use to run non-blocking I/O requests- Parameters:
numThreads
- The number of threads that the event loop group may run tasks across. Usually 1.- Throws:
CrtRuntimeException
- If the system is unable to allocate space for a native event loop group
-
EventLoopGroup
public EventLoopGroup(int cpuGroup, int numThreads) throws CrtRuntimeException
Creates a new event loop group for the I/O subsystem to use to run non-blocking I/O requests. When using this constructor, the threads will be pinned to a particular cpuGroup (e.g. a particular NUMA node).- Parameters:
cpuGroup
- the index of the cpu group to bind to (for example NUMA node 0 would be 0, NUMA node 1 would be 1 etc...)numThreads
- The number of threads that the event loop group may run tasks across. Usually 1.- Throws:
CrtRuntimeException
- If the system is unable to allocate space for a native event loop group
-
-
Method Detail
-
canReleaseReferencesImmediately
protected boolean canReleaseReferencesImmediately()
Determines whether a resource releases its dependencies at the same time the native handle is released or if it waits. Resources that wait are responsible for calling releaseReferences() manually.- Specified by:
canReleaseReferencesImmediately
in classCrtResource
- Returns:
- true if this resource releases synchronously, false if this resource performs async shutdown
-
releaseNativeHandle
protected void releaseNativeHandle()
Stops the event loop group's tasks and frees all resources associated with the the group. This should be called after all other clients/connections and other resources are cleaned up, or else they will not clean up completely.- Specified by:
releaseNativeHandle
in classCrtResource
-
getShutdownCompleteFuture
public CompletableFuture<Void> getShutdownCompleteFuture()
-
setStaticDefaultNumThreads
public static void setStaticDefaultNumThreads(int numThreads)
Sets the number of threads for the static default event loop group, should it ever be created. Has no effect if the static default event loop group has already been created.- Parameters:
numThreads
- number of threads for the static default event loop group
-
closeStaticDefault
public static void closeStaticDefault()
Closes the static default event loop group, if it exists. Primarily intended for tests that use the static default event loop group, before they call waitForNoResources().
-
-