Class Synchapi


  • @Include("synchapi.h")
    public abstract class Synchapi
    extends Object
    Wrapper around the synchapi.h header.
    Author:
    aploese
    • Constructor Detail

      • Synchapi

        public Synchapi()
    • Method Detail

      • CreateEventW

        public static final Winnt.HANDLE CreateEventW​(Minwinbase.SECURITY_ATTRIBUTES lpEventAttributes,
                                                      boolean bManualReset,
                                                      boolean bInitialState,
                                                      String lpName)
                                               throws NativeErrorException
        CreateEventW Creates or opens a named or unnamed event object.
        Parameters:
        lpEventAttributes - a pointer to a SECURITY_ATTRIBUTES structure. If this parameter is NULL, the handle cannot be inherited by child processes.
        bManualReset - If this parameter is TRUE, the function creates a manual-reset event object, which requires the use of the ResetEvent function to set the event state to nonsignaled. If this parameter is FALSE, the function creates an auto-reset event object, and system automatically resets the event state to nonsignaled after a single waiting thread has been released.
        bInitialState - If this parameter is TRUE, the initial state of the event object is signaled; otherwise, it is nonsignaled.
        lpName - The name of the event object. The name is limited to MAX_PATH characters. Name comparison is case sensitive. If lpName is NULL, the event object is created without a name.
        Returns:
        If the function succeeds, the return value is a handle to the event object.
        Throws:
        NativeErrorException - if the return value of the native function indicates an error.
      • SleepEx

        public static final long SleepEx​(long dwMilliseconds,
                                         boolean bAlertable)
        SleepEx Sets the specified event object to the signaled state.
        Parameters:
        dwMilliseconds - The time interval for which execution is to be suspended, in milliseconds.
        bAlertable - enable/disable APC.
        Returns:
        The return value is zero if the specified time interval expired. The return value is WAIT_IO_COMPLETION if the function returned due to one or more I/O completion callback functions.
      • WaitForMultipleObjects

        public static final long WaitForMultipleObjects​(Winnt.ArrayOfHandle lpHandles,
                                                        boolean bWaitAll,
                                                        long dwMilliseconds)
                                                 throws NativeErrorException
        WaitForSingleObject Waits until one or all of the specified objects are in the signaled state or the time-out interval elapses.
        Parameters:
        lpHandles - An array of object handles.
        bWaitAll - If this parameter is TRUE, the function returns when the state of all objects in the lpHandles array is signaled. If FALSE, the function returns when the state of any one of the objects is set to signaled. In the latter case, the return value indicates the object whose state caused the function to return.
        dwMilliseconds - the time-out interval, in milliseconds.
        Returns:
        If the function succeeds, the return value indicates the event that caused the function to return. It can be one of the following values. (Note that WAIT_OBJECT_0 is defined as 0 and WAIT_ABANDONED_0 is defined as 0x00000080L.)
        Throws:
        NullPointerException - if hHandle is null.
        NativeErrorException - if the return value of the native function indicates an error.
      • WaitForMultipleObjectsEx

        public static final long WaitForMultipleObjectsEx​(Winnt.ArrayOfHandle lpHandles,
                                                          boolean bWaitAll,
                                                          long dwMilliseconds,
                                                          boolean bAlertable)
                                                   throws NativeErrorException
        WaitForSingleObjectEx Waits until the specified object is in the signaled state, an I/O completion routine or asynchronous procedure call (APC) is queued to the thread, or the time-out interval elapses.
        Parameters:
        lpHandles - An array of object handles.
        bWaitAll - If this parameter is TRUE, the function returns when the state of all objects in the lpHandles array is signaled. If FALSE, the function returns when the state of any one of the objects is set to signaled. In the latter case, the return value indicates the object whose state caused the function to return.
        dwMilliseconds - the time-out interval, in milliseconds.
        bAlertable - If this parameter is TRUE and the thread is in the waiting state, the function returns when the system queues an I/O completion routine or APC, and the thread runs the routine or function. Otherwise, the function does not return, and the completion routine or APC function is not executed.
        Returns:
        If the function succeeds, the return value indicates the event that caused the function to return. It can be one of the following values. (Note that WAIT_OBJECT_0 is defined as 0 and WAIT_ABANDONED_0 is defined as 0x00000080L.)
        Throws:
        NullPointerException - if hHandle is null.
        NativeErrorException - if the return value of the native function indicates an error.
      • WaitForSingleObject

        public static final long WaitForSingleObject​(Winnt.HANDLE hHandle,
                                                     long dwMilliseconds)
                                              throws NativeErrorException
        WaitForSingleObject Waits until the specified object is in the signaled state or the time-out interval elapses.
        Parameters:
        hHandle - A handle to the object.
        dwMilliseconds - the time-out interval, in milliseconds.
        Returns:
        on succes one of WAIT_ABANDONED, WAIT_OBJECT_0 or WAIT_TIMEOUT.
        Throws:
        NullPointerException - if hHandle is null.
        NativeErrorException - if the return value of the native function indicates an error.
      • WaitForSingleObjectEx

        public static final long WaitForSingleObjectEx​(Winnt.HANDLE hHandle,
                                                       long dwMilliseconds,
                                                       boolean bAlertable)
                                                throws NativeErrorException
        WaitForSingleObjectEx Waits until the specified object is in the signaled state, an I/O completion routine or asynchronous procedure call (APC) is queued to the thread, or the time-out interval elapses.
        Parameters:
        hHandle - A handle to the object.
        dwMilliseconds - the time-out interval, in milliseconds.
        bAlertable - If this parameter is TRUE and the thread is in the waiting state, the function returns when the system queues an I/O completion routine or APC, and the thread runs the routine or function. Otherwise, the function does not return, and the completion routine or APC function is not executed.
        Returns:
        on succes one of WAIT_ABANDONED, WAIT_OBJECT_0 or WAIT_TIMEOUT.
        Throws:
        NullPointerException - if hHandle is null.
        NativeErrorException - if the return value of the native function indicates an error.