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       * Set the thread Data.
50       *
51       * @param pSteps the reporting steps
52       */
53      void setReportingSteps(int pSteps);
54  
55      /**
56       * Get error.
57       *
58       * @return the error
59       */
60      Throwable getError();
61  
62      /**
63       * Set the thread Data.
64       *
65       * @param pThreadData the threadData
66       */
67      void setThreadData(Object pThreadData);
68  
69      /**
70       * Obtain the thread data.
71       *
72       * @return the threadData
73       */
74      Object getThreadData();
75  
76      /**
77       * Start a thread.
78       *
79       * @param <T>     the thread result
80       * @param pThread the thread to start
81       */
82      <T> void startThread(TethysUIThread<T> pThread);
83  
84      /**
85       * Shut down the thread manager.
86       */
87      void shutdown();
88  
89      /**
90       * cancel the worker.
91       */
92      void cancelWorker();
93  
94      /**
95       * Obtain the active profile.
96       *
97       * @return the active profile
98       */
99      OceanusProfile getActiveProfile();
100 
101     /**
102      * Create new profile.
103      *
104      * @param pTask the name of the task
105      */
106     void setNewProfile(String pTask);
107 }