/**
 * This file has no copyright assigned and is placed in the Public Domain.
 * This file is part of the mingw-w64 runtime package.
 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
 */

#ifdef __WIDL__
#pragma winrt ns_prefix
#endif

import "inspectable.idl";
import "windows.foundation.idl";

namespace Windows {
    namespace Foundation {
        interface IAsyncAction;
        struct TimeSpan;
    }

    namespace System {
        namespace Threading {
            typedef enum WorkItemPriority WorkItemPriority;
            typedef enum WorkItemOptions WorkItemOptions;
            interface TimerElapsedHandler;   //delegate
            interface TimerDestroyedHandler; //delegate
            interface WorkItemHandler;       //delegate
            interface IThreadPoolStatics;
            interface IThreadPoolTimer;
            interface IThreadPoolTimerStatics;
        }
    }
}

namespace Windows {
    namespace System {
        namespace Threading
        {
            enum WorkItemPriority {
                Low    = -1,
                Normal = 0,
                High   = 1
            };

            enum WorkItemOptions {
                None       = 0,
                TimeSliced = 1
            };

            typedef struct TimeSpan {
                INT64 Duration;
            } TimeSpan;

            [uuid(FAAEA667-FBEB-49CB-ADB2-71184C556E43)]
            interface TimerElapsedHandler : IUnknown {
                HRESULT Invoke(IThreadPoolTimer* timer);
            }

            [uuid(34ED19FA-8384-4EB9-8209-FB5094EEEC35)]
            interface TimerDestroyedHandler : IUnknown {
                HRESULT Invoke(IThreadPoolTimer* timer);
            }

            [uuid(1D1A8B8B-FA66-414F-9CBD-B65FC99D17FA)]
            interface WorkItemHandler : IUnknown {
                HRESULT Invoke(
                        Windows.Foundation.IAsyncAction* operation);
            }

            [uuid(B6BF67DD-84BD-44F8-AC1C-93EBCB9DBA91)]
            interface IThreadPoolStatics : IInspectable
            {
                HRESULT RunAsync(
                        WorkItemHandler* handler,
                        Windows.Foundation.IAsyncAction** operation);

                HRESULT RunWithPriorityAsync(
                        WorkItemHandler* handler,
                        WorkItemPriority priority,
                        Windows.Foundation.IAsyncAction** operation);

                HRESULT RunWithPriorityAndOptionsAsync(
                        WorkItemHandler* handler,
                        WorkItemPriority priority,
                        WorkItemOptions options,
                        Windows.Foundation.IAsyncAction** operation);
            }

            [uuid(594EBE78-55EA-4A88-A50D-3402AE1F9CF2)]
            interface IThreadPoolTimer : IInspectable
            {
                [propget] HRESULT Period(TimeSpan* value);
                [propget] HRESULT Delay(TimeSpan* value);
                HRESULT Cancel();
            }

            [uuid(1A8A9D02-E482-461B-B8C7-8EFAD1CCE590)]
            interface IThreadPoolTimerStatics : IInspectable
            {
                HRESULT CreatePeriodicTimer(
                        TimerElapsedHandler* handler,
                        TimeSpan period,
                        IThreadPoolTimer** timer);

                HRESULT CreateTimer(
                        TimerElapsedHandler* handler,
                        TimeSpan delay,
                        IThreadPoolTimer** timer);

                HRESULT CreatePeriodicTimerWithCompletion(
                        TimerElapsedHandler* handler,
                        TimeSpan period,
                        TimerDestroyedHandler* destroyed,
                        IThreadPoolTimer** timer);

                HRESULT CreateTimerWithCompletion(
                        TimerElapsedHandler* handler,
                        TimeSpan delay,
                        TimerDestroyedHandler* destroyed,
                        IThreadPoolTimer** timer);
            }
        }
    }
}
