View Javadoc
1   /*
2    * Tethys: GUI Utilities
3    * Copyright 2012-2026. Tony Washer
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6    * use this file except in compliance with the License.  You may obtain a copy
7    * of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
14   * License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  package io.github.tonywasher.joceanus.tethys.api.thread;
18  
19  import io.github.tonywasher.joceanus.oceanus.event.OceanusEventRegistrar.OceanusEventProvider;
20  import io.github.tonywasher.joceanus.oceanus.profile.OceanusProfile;
21  
22  /**
23   * Thread Manager.
24   */
25  public interface TethysUIThreadManager
26          extends OceanusEventProvider<TethysUIThreadEvent>, TethysUIThreadStatusReport {
27      /**
28       * Obtain the status manager.
29       *
30       * @return the status Manager
31       */
32      TethysUIThreadStatusManager getStatusManager();
33  
34      /**
35       * obtain the task name.
36       *
37       * @return the task name
38       */
39      String getTaskName();
40  
41      /**
42       * Do we have a running thread.
43       *
44       * @return true/false
45       */
46      boolean hasWorker();
47  
48      /**
49       * Get error.
50       *
51       * @return the error
52       */
53      Throwable getError();
54  
55      /**
56       * Set the thread Data.
57       *
58       * @param pThreadData the threadData
59       */
60      void setThreadData(Object pThreadData);
61  
62      /**
63       * Start a thread.
64       *
65       * @param <T>     the thread result
66       * @param pThread the thread to start
67       */
68      <T> void startThread(TethysUIThread<T> pThread);
69  
70      /**
71       * Shut down the thread manager.
72       */
73      void shutdown();
74  
75      /**
76       * cancel the worker.
77       */
78      void cancelWorker();
79  
80      /**
81       * Obtain the active profile.
82       *
83       * @return the active profile
84       */
85      OceanusProfile getActiveProfile();
86  
87      /**
88       * Create new profile.
89       *
90       * @param pTask the name of the task
91       */
92      void setNewProfile(String pTask);
93  
94      /**
95       * Register thread completion.
96       */
97      void threadCompleted();
98  }