File tree Expand file tree Collapse file tree 1 file changed +31
-21
lines changed
src/main/java/org/usb4java/javax Expand file tree Collapse file tree 1 file changed +31
-21
lines changed Original file line number Diff line number Diff line change @@ -83,33 +83,43 @@ final void process()
8383 {
8484 // Get the next IRP
8585 T irp = this .irps .poll ();
86- while (irp != null )
86+
87+ // If there are no IRPs to process then mark the thread as closing
88+ // right away. Otherwise process the IRP (and more IRPs from the queue
89+ // if present).
90+ if (irp == null )
8791 {
88- // Process the IRP
89- try
90- {
91- processIrp (irp );
92- }
93- catch (final UsbException e )
92+ this .processor = null ;
93+ }
94+ else
95+ {
96+ while (irp != null )
9497 {
95- irp .setUsbException (e );
98+ // Process the IRP
99+ try
100+ {
101+ processIrp (irp );
102+ }
103+ catch (final UsbException e )
104+ {
105+ irp .setUsbException (e );
106+ }
107+
108+ // Get next IRP and mark the thread as closing before sending the
109+ // events for the previous IRP
110+ final T nextIrp = this .irps .poll ();
111+ if (nextIrp == null ) this .processor = null ;
112+
113+ // Finish the previous IRP
114+ irp .complete ();
115+ finishIrp (irp );
116+
117+ // Process next IRP (if present)
118+ irp = nextIrp ;
96119 }
97-
98- // Get next IRP and mark the thread as closing before sending the
99- // events for the previous IRP
100- final T nextIrp = this .irps .poll ();
101- if (nextIrp == null ) this .processor = null ;
102-
103- // Finish the previous IRP
104- irp .complete ();
105- finishIrp (irp );
106-
107- // Process next IRP (if present)
108- irp = nextIrp ;
109120 }
110121
111122 // No more IRPs are present in the queue so terminate the thread.
112- this .processor = null ;
113123 synchronized (this .irps )
114124 {
115125 this .irps .notifyAll ();
You can’t perform that action at this time.
0 commit comments