Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Threading #14

Open
riewert opened this issue Jan 29, 2021 · 0 comments
Open

Threading #14

riewert opened this issue Jan 29, 2021 · 0 comments

Comments

@riewert
Copy link

riewert commented Jan 29, 2021

In practice AbstractIrpQueue spawns a new thread whenever an Irp is added. For asyncSubmit this makes a little sense, though reusing the a single thread per pipe would be a lot better. For the syncSubmit usecase it makes no sense to do this. It is very resource intense. By making the following modification I was able to increase performance by a factor of 10x.

    public final void add(final T irp)
    {
        this.irps.add(irp);

        // Start the queue processor if not already running.
//        if (this.processor == null)
//        {
//            this.processor = new Thread(new Runnable()
//            {
//                @Override
//                public void run()
//                {
                    process();
//                }
//            });
//            this.processor.setDaemon(true);
//            this.processor.setName("usb4java IRP Queue Processor");
//            this.processor.start();
//        }
    }

When using syncSubmit an Irp is added to the queue, and the processor thread is started, when the processor finishes executing the Irp the thread is destroyed again. Meanwhile the syncSubmit thread is waiting. A cleaner solution might be to wait() the processor thread until a new irp is added. That would work for asyncSubmit too. But is not relevant for my usecase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant