Class 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.
    • 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 class CrtResource
        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 class CrtResource
      • 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().