Archived

This forum has been archived. Please start a new discussion on GitHub.

What is the default priority of the Ice thread ?

Hi,
What is the default priority of the Ice thread ?Can I set the priority of the Ice thread?

Thanks,

Comments

  • marc
    marc Florida
    Ice does not change thread priorities, so the priority of a thread is whatever the operating system chooses as default. Ice does also not have an API to change thread priority. You have to do this using the native thread API of your platform.
  • Hi marc,
    I used Ice-3.2.0, using the thread-pool model in windows 2003 server.As you saying, Ice does not change thread priorities.This is to say,there is no way to change the thread priorities?

    Thanks,
  • marc
    marc Florida
    No, you cannot change the priorities of the threads from the thread pool.
  • bernard
    bernard Jupiter, FL
    While Ice does not provide some special thread-priority setting, it gives you the ability to register a callback that runs in any thread created by an Ice communicator:
    class ThreadNotification : public IceUtil::Shared
    {
    public:
    
        virtual void start() = 0;
        virtual void stop() = 0;
    };
    
    typedef IceUtil::Handle<ThreadNotification> ThreadNotificationPtr;
    
    //
    // Communicator initialization info
    //
    struct InitializationData
    {
        PropertiesPtr properties;
        LoggerPtr logger;
        StatsPtr stats;
        StringConverterPtr stringConverter;
        WstringConverterPtr wstringConverter;
        ThreadNotificationPtr threadHook;
    };
    

    In start() you could change the priority of the current thread, e.g. implement start as:
    SetThreadPriority(GetCurrentThread(), THREAD_MODE_BACKGROUND_BEGIN);
    

    Please note:
    - we did not test such thread-priority modification
    - this thread-notification callback applies to all threads created by a communicator, not just the threads in a specific thread pool

    Best regards,
    Bernard
  • Hi bernard,
    I tried this method, and it can change the priorities of the threads created by an Ice communicator to register a callback .

    Thank you very much!