[OpenJDK 2D-Dev] RFR: 8263311: Watch registry changes for remote printers update instead of polling

Prasanta Sadhukhan psadhukhan at openjdk.java.net
Thu Mar 11 11:34:23 UTC 2021


On Thu, 11 Mar 2021 10:54:12 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp line 259:
>> 
>>> 257:                                                          NULL,
>>> 258:                                                          FALSE);
>>> 259:         if (keepMonitoring) {
>> 
>> I guess having "FALSE" as fAsynchronous  value mean the function does not return until a change has occurred so do we still need this do-while monitoring loop? And if the function fails once, should we stop monitoring?
>
>> I guess having "FALSE" as fAsynchronous value mean the function does not return until a change has occurred so do we still need this do-while monitoring loop?
> 
> You're right, `FALSE` for `fAsynchronous` means the function doesn't return until a change occurred.
> 
> If a change occurs, we refresh the list of print services and then start to wait again. If we exit the loop, we'll not catch other changes that may occur.
> 
>> And if the function fails once, should we stop monitoring?
> I followed Sergey's approach in `notifyLocalPrinterChange`, namely if `FindNextPrinterChangeNotification` returns an error, we quit the loop.
> 
> I can't see how we can fix the error if it occurs. Will it succeed the next time? Probably not. Thus I decided to quit the loop in case of an error.

I also am not sure on this. But I think since this is for remote printer, sometimes network availability issue might be there so it may fail more compared to local printer so I guess we should give this method a fair chance, more than that of local printer change, and not bail out on one failure.....maybe try out after some duration...or 5 times spaced out...as you did for the other EnumPrinter fix..

-------------

PR: https://git.openjdk.java.net/jdk/pull/2915


More information about the 2d-dev mailing list