You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2019/09/20 13:20:08 UTC
[isis] branch v2 updated: ISIS-2062: copied Andi's notes on
ConcurrentTaskList
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch v2
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/v2 by this push:
new 769971a ISIS-2062: copied Andi's notes on ConcurrentTaskList
769971a is described below
commit 769971a29bb1ad6df0ed96da1d12f319f22330f4
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Fri Sep 20 14:19:55 2019 +0100
ISIS-2062: copied Andi's notes on ConcurrentTaskList
---
.../modules/ROOT/pages/concurrent-task-list.adoc | 64 ++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/antora/components/archdesign/modules/ROOT/pages/concurrent-task-list.adoc b/antora/components/archdesign/modules/ROOT/pages/concurrent-task-list.adoc
new file mode 100644
index 0000000..fefc81e
--- /dev/null
+++ b/antora/components/archdesign/modules/ROOT/pages/concurrent-task-list.adoc
@@ -0,0 +1,64 @@
+= Concurrent Task List
+:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or ag [...]
+
+include::_attributes.adoc[]
+
+Dan::
+I also saw you were doing some work on async background jobs, are you happy with the design ?
+
+
+Andi::
+the 'wrapper' got an extension to also run actions asynchronous; thats cool but I'm missing a means to get hold of the Future object that is produced in the background, that would be really nice
+
+Dan::
+Perhaps a request scoped service could pull them together as they are created?
+
+Andi::
+another thing is, I removed the ThreadPoolSupport in favour of a more convenient concept: ConcurrentTask and ConcurrentTaskList
+
+Dan::
+^ yes, that was what I noticed.
++
+The TPS was for internal use to perform parallel introspection etc, so does ConcurrentTask list provide the same capability?
+and does the wrapper use this new concept also?
+
+Andi::
+Basically I've replaced all 'concurrent executors' with the common ForkJoinPool ... ForkJoinPool.commonPool();
++
+this might or might not be the better default
++
+ConcurrentTaskList however allows to provide a custom executor if needed. I believe the JDK does provide good ready to use executors, so that we don't need to write our own.
+
+Dan::
+OK, good enough for me.
+
+Andi::
+ConcurrentTaskList and its co-operator classes reside in the internal API section of the 'commons' module, however they don't follow the _ prefixed scheme. I was in conflict with whether to move them up in the package hierarchy to make them also official usable by Isis coders. I decided 'not-yet' so we might want to add the prefixes.
+
+Dan::
+Yes, I'd prefer that : "_" to mean internal. If we do decide to make them formal API, we can refactor our internal code that uses it
+
+Andi::
+most simple usecase scenario ...
++
+[source,java]
+----
+val taskList = ConcurrentTaskList.named("Isis Application Background Initialization Tasks")
+.addRunnable("Configure WebJars", this::configureWebJars)
+.addRunnable("Configure WicketBootstrap", this::configureWicketBootstrap)
+.addRunnable("Configure WicketSelect2", this::configureWicketSelect2);
+
+taskList.submit(ConcurrentContext.sequential()); // runs these tasks within provided execution context
+
+taskList.await(); // block current thread and wait for all tasks to complete
+----
++
+taskList also provides access to all the tasks it contains, and one can check their individual stati; this is also easily extensible
+
+
+Andi::
+any exceptions that occur in individual tasks are stored in their corresponding ConcurrentTask object, along with execution time;
++
+whether to log or not log a summary of the task list execution result is decided by a flag in the ConcurrentContext as provided to the submit method
++
+NOTE: I've recently learned, that with newer JDKs (unfortunately not in 8) one could emit flight recorder events to the JVM, such that you would see these events in eg. Java Mission Control. This would allow to record task execution timings directly to the JVM.