package NThreading;


// "Polymorphic" options collection (suitable for multiple queue types)
message TPoolOpts {
    enum ECpuClass {
        None = 0; // do not change (inherit)
        Rt = 1;   // inherit, and try to obtain Realtime sheduling
        NoRt = 2; // inherit, and avoid Realtime sheduling
        Batch = 3; // batch scheduling (SCHED_BATCH)
    }

    enum EIoClass {
        IoNone = 0; // do not change
        IoIdle = 3; // IOPRIO_CLASS_IDLE
    }

    // defines which IThreadPool + IMtpQueue implementations to use
    enum EPoolType {
        Default = 0; // autodetect
        Std = 1;     // TSimpleMtpQueue + SystemThreadFactory
        Prio = 2;    // TSimpleMtpQueue + TPriorityThreadPool
        Smart = 3;   // TSmartMtpQueue + TPriorityThreadPool
        HiLow = 4;   // TSmartMtpQueueNg + TPriorityThreadPool
    }

    optional EPoolType Type = 1 [default = Default]; // Default = Prio when prio is set, HiLow when hi-low opts are set

    // Prio and HiLow options
    optional ECpuClass Cpu = 2 [default = None];
    optional EIoClass Io = 3 [default = IoNone];
    optional sint32 NiceVl = 4 [default = 0]; // CPU nice value
    // optional sint32 IoNiceVl = 5 [default = 0]; // IO nice value

    // HiLow options
    optional int32 Low = 5 [default = 1];
    optional float HiMult = 6 [default = 1]; // Hi >= Low * HiMult + HiAdd
    optional sint32 HiAdd = 7 [default = 0];
    optional int32 HiLimit = 12 [default = 0]; // allows to lower MaxThreads below the Start() value
    optional int32 Step = 8 [default = 1];
    optional float HiQueueJobs = 9 [default = 1.3]; // desirable queue size = nThreads * HiQueueJobs
    optional float HiQueueBurst = 10 [default = 3]; // burst threshold queue size = nThreads * HiQueueBurst

    // AllocOptions (for Balloc)
    optional bool NoAlloc = 11;
}

// Load type to be matched with TPoolOpts
enum TLoadtype {
    Undefined = 0;  // as is
    Primary = 1;       // primary (search or lookup) requests that account for the main load
    Fetch = 2;      // follow-up requests (factors, snippets)
    Update = 3;     // non-interactive 'background' requests with latency requirements (Indexer)
    Batch = 4;      // regular 'background' batch operations with no latency requirements (Merger)
    Service = 5;    // offline operations, and irregular batch operations with no latency requirements (maintainance)
};


option optimize_for = CODE_SIZE; // enable reflection
