hypfvieh / dbus-java

Improved version of java DBus library provided by freedesktop.org (https://dbus.freedesktop.org/doc/dbus-java/)
https://hypfvieh.github.io/dbus-java/
MIT License
185 stars 73 forks source link

Feature request: Set thread priority in NameableThreadFactory #173

Closed ghost closed 2 years ago

ghost commented 2 years ago

In our application, we have, essentially, two high-priority, real-time processing threads. The rest of the application assigns threads to low-priority. The following lines in NameableThreadFactory pin the thread to priority level 5:

    if (t.getPriority() != 5) {
        t.setPriority(5);
    }

(Aside, is that if condition superfluous? Could the code set the priority regardless of its current value? Setting pri 5 back to pri 5 would effectively be a no-op.)

We'd like to build a DBusConnection to process signals at the lowest possible priority level, such as:

return DBusConnectionBuilder
  .forSessionBus()
  .withThreadPriority(Thread.MIN_PRIORITY)
  .build();
hypfvieh commented 2 years ago

I added the option to change the priority for every thread factory used in ReceivingService using DBusConnectioBuilder/DirectConnectionBuilder. Please check if this is suitable for you.