Description
Rather than trying to code in the threading models and Selectors for a DataSource and it's Connections, allow them to be configured externally.
A primary use case for this is sharing the HTTP Selector. By allowing the NIO loop to be provided to the DataSource for it's connections it allows the HTTP Selector and threads to be used to service the communication with the database. This will allow a single thread to service HTTP requests, which is my understanding of the aim of NIO.
This is further work on #12 .
Example code (not yet working) available to demonstrate the concept:
https://github.com/sagenschneider/pgsql2/blob/281b7fcecd8c54a8041680d654ea9de9404427ff/src/main/java/org/postgresql/sql2/PGDataSource.java#L45 (shows how the NioLoop can be provided to the DataSource with a reasonable default)
https://github.com/sagenschneider/pgsql2/blob/281b7fcecd8c54a8041680d654ea9de9404427ff/src/main/java/org/postgresql/sql2/execution/NioLoop.java#L1 (NioLoop that may be implemented by the web server to share it's HTTP Selector with the DataSource)
https://github.com/sagenschneider/pgsql2/blob/281b7fcecd8c54a8041680d654ea9de9404427ff/src/main/java/org/postgresql/sql2/communication/ProtocolV3.java#L65 (using NioLoop for communication to database)
Activity