Home Help Center

What is the default priority of the Ice thread ?

russulerussule Member Lei ChunOrganization: www.channelsoft.com.cnProject: Conf ✭✭
Hi,
What is the default priority of the Ice thread ?Can I set the priority of the Ice thread?

Thanks,

Comments

  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    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.
  • russulerussule Member Lei ChunOrganization: www.channelsoft.com.cnProject: Conf ✭✭
    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,
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    No, you cannot change the priorities of the threads from the thread pool.
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    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
  • russulerussule Member Lei ChunOrganization: www.channelsoft.com.cnProject: Conf ✭✭
    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!
Sign In or Register to comment.