@Override
        public final ContentChannel handleRequest(final Request request, final ResponseHandler responseHandler) {
            // Ensure that task executor is not shut down before handleResponse() is done.
            final TaskHandle handleResponseTask = addTask();
            try {
                final ContentChannel requestContentChannel = handle(request, responseHandler);
                if (requestContentChannel == null) {
                    return null;
                }
                // Ensure that task executor is not shut down before close() is done.
                final TaskHandle requestContentChannelCloseTask = addTask();
                return new ContentChannel() {
                    @Override
                    public void write(ByteBuffer buf, CompletionHandler handler) {
                        requestContentChannel.write(buf, handler);
                    }

                    @Override
                    public void close(CompletionHandler handler) {
                        try {
                            requestContentChannel.close(handler);
                        } finally {
                            removeTask(requestContentChannelCloseTask);
                        }
                    }
                };
            } finally {
                removeTask(handleResponseTask);
            }
        }
Wrapper around CountDownLatch for single-occurrence events.
jdisc_core/src/main/java/com/yahoo/jdisc/test/ServerProviderConformanceTest.java