diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llcommon/llrun.h | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llcommon/llrun.h')
-rw-r--r-- | linden/indra/llcommon/llrun.h | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/linden/indra/llcommon/llrun.h b/linden/indra/llcommon/llrun.h new file mode 100644 index 0000000..696a226 --- /dev/null +++ b/linden/indra/llcommon/llrun.h | |||
@@ -0,0 +1,163 @@ | |||
1 | /** | ||
2 | * @file llrun.h | ||
3 | * @author Phoenix | ||
4 | * @date 2006-02-16 | ||
5 | * @brief Declaration of LLRunner and LLRunnable classes. | ||
6 | * | ||
7 | * Copyright (c) 2006-2007, Linden Research, Inc. | ||
8 | * | ||
9 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
10 | * to you under the terms of the GNU General Public License, version 2.0 | ||
11 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
12 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
13 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
14 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
15 | * | ||
16 | * There are special exceptions to the terms and conditions of the GPL as | ||
17 | * it is applied to this Source Code. View the full text of the exception | ||
18 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
19 | * online at http://secondlife.com/developers/opensource/flossexception | ||
20 | * | ||
21 | * By copying, modifying or distributing this software, you acknowledge | ||
22 | * that you have read and understood your obligations described above, | ||
23 | * and agree to abide by those obligations. | ||
24 | * | ||
25 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
26 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
27 | * COMPLETENESS OR PERFORMANCE. | ||
28 | */ | ||
29 | |||
30 | #ifndef LL_LLRUN_H | ||
31 | #define LL_LLRUN_H | ||
32 | |||
33 | #include <vector> | ||
34 | #include <boost/shared_ptr.hpp> | ||
35 | |||
36 | class LLRunnable; | ||
37 | |||
38 | /** | ||
39 | * @class LLRunner | ||
40 | * @brief This class manages a set of LLRunnable objects. | ||
41 | * | ||
42 | * An instance of this class has a collection of LLRunnable objects | ||
43 | * which are scheduled to run on a repeating or one time basis. | ||
44 | * @see LLRunnable | ||
45 | */ | ||
46 | class LLRunner | ||
47 | { | ||
48 | public: | ||
49 | /** | ||
50 | * @brief The pointer to a runnable. | ||
51 | */ | ||
52 | typedef boost::shared_ptr<LLRunnable> run_ptr_t; | ||
53 | |||
54 | /** | ||
55 | * @brief The handle for use in the API. | ||
56 | */ | ||
57 | typedef S64 run_handle_t; | ||
58 | |||
59 | /** | ||
60 | * @brief Constructor. | ||
61 | */ | ||
62 | LLRunner(); | ||
63 | |||
64 | /** | ||
65 | * @brief Destructor. | ||
66 | */ | ||
67 | ~LLRunner(); | ||
68 | |||
69 | /** | ||
70 | * @brief Enumeration which specifies when to run. | ||
71 | */ | ||
72 | enum ERunSchedule | ||
73 | { | ||
74 | // The runnable will run in N seconds | ||
75 | RUN_IN, | ||
76 | |||
77 | // The run every N seconds | ||
78 | RUN_EVERY, | ||
79 | |||
80 | // A count of the run types | ||
81 | RUN_SCHEDULE_COUNT | ||
82 | }; | ||
83 | |||
84 | /** | ||
85 | * @brief Run the runnables which are scheduled to run | ||
86 | * | ||
87 | * @return Returns the number of runnables run. | ||
88 | */ | ||
89 | S32 run(); | ||
90 | |||
91 | /** | ||
92 | * @brief Add a runnable to the run list. | ||
93 | * | ||
94 | * The handle of the runnable is unique to each addition. If the | ||
95 | * same runnable is added a second time with the same or different | ||
96 | * schedule, this method will return a new handle. | ||
97 | * @param runnable The runnable to run() on schedule. | ||
98 | * @param schedule Specifies the run schedule. | ||
99 | * @param seconds When to run the runnable as interpreted by schedule. | ||
100 | * @return Returns the handle to the runnable. handle == 0 means failure. | ||
101 | */ | ||
102 | run_handle_t addRunnable( | ||
103 | run_ptr_t runnable, | ||
104 | ERunSchedule schedule, | ||
105 | F64 seconds); | ||
106 | |||
107 | /** | ||
108 | * @brief Remove the specified runnable. | ||
109 | * | ||
110 | * @param handle The handle of the runnable to remove. | ||
111 | * @return Returns the pointer to the runnable removed which may | ||
112 | * be empty. | ||
113 | */ | ||
114 | run_ptr_t removeRunnable(run_handle_t handle); | ||
115 | |||
116 | protected: | ||
117 | struct LLRunInfo | ||
118 | { | ||
119 | run_handle_t mHandle; | ||
120 | run_ptr_t mRunnable; | ||
121 | ERunSchedule mSchedule; | ||
122 | F64 mNextRunAt; | ||
123 | F64 mIncrement; | ||
124 | LLRunInfo( | ||
125 | run_handle_t handle, | ||
126 | run_ptr_t runnable, | ||
127 | ERunSchedule schedule, | ||
128 | F64 next_run_at, | ||
129 | F64 increment); | ||
130 | }; | ||
131 | typedef std::vector<LLRunInfo> run_list_t; | ||
132 | run_list_t mRunOnce; | ||
133 | run_list_t mRunEvery; | ||
134 | run_handle_t mNextHandle; | ||
135 | }; | ||
136 | |||
137 | |||
138 | /** | ||
139 | * @class LLRunnable | ||
140 | * @brief Abstract base class for running some scheduled process. | ||
141 | * | ||
142 | * Users of the LLRunner class are expected to derive a concrete | ||
143 | * implementation of this class which overrides the run() method to do | ||
144 | * something useful. | ||
145 | * @see LLRunner | ||
146 | */ | ||
147 | class LLRunnable | ||
148 | { | ||
149 | public: | ||
150 | LLRunnable(); | ||
151 | virtual ~LLRunnable(); | ||
152 | |||
153 | /** | ||
154 | * @brief Do the process. | ||
155 | * | ||
156 | * This method will be called from the LLRunner according to | ||
157 | * @param runner The Runner which call run(). | ||
158 | * @param handle The handle this run instance is run under. | ||
159 | */ | ||
160 | virtual void run(LLRunner* runner, S64 handle) = 0; | ||
161 | }; | ||
162 | |||
163 | #endif // LL_LLRUN_H | ||