diff options
Diffstat (limited to 'linden/indra/llvfs/lllfsthread.h')
-rw-r--r-- | linden/indra/llvfs/lllfsthread.h | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/linden/indra/llvfs/lllfsthread.h b/linden/indra/llvfs/lllfsthread.h new file mode 100644 index 0000000..8af66b1 --- /dev/null +++ b/linden/indra/llvfs/lllfsthread.h | |||
@@ -0,0 +1,138 @@ | |||
1 | /** | ||
2 | * @file lllfsthread.h | ||
3 | * @brief LLLFSThread base class | ||
4 | * | ||
5 | * Copyright (c) 2000-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LL_LLLFSTHREAD_H | ||
29 | #define LL_LLLFSTHREAD_H | ||
30 | |||
31 | #include <queue> | ||
32 | #include <string> | ||
33 | #include <map> | ||
34 | #include <set> | ||
35 | |||
36 | #include "llapr.h" | ||
37 | |||
38 | #include "llqueuedthread.h" | ||
39 | |||
40 | //============================================================================ | ||
41 | // Threaded Local File System | ||
42 | //============================================================================ | ||
43 | |||
44 | class LLLFSThread : public LLQueuedThread | ||
45 | { | ||
46 | //------------------------------------------------------------------------ | ||
47 | public: | ||
48 | enum operation_t { | ||
49 | FILE_READ, | ||
50 | FILE_WRITE, | ||
51 | FILE_RENAME, | ||
52 | FILE_REMOVE | ||
53 | }; | ||
54 | |||
55 | //------------------------------------------------------------------------ | ||
56 | public: | ||
57 | |||
58 | class Request : public QueuedRequest | ||
59 | { | ||
60 | protected: | ||
61 | ~Request() {}; // use deleteRequest() | ||
62 | |||
63 | public: | ||
64 | Request(handle_t handle, U32 priority, U32 flags, | ||
65 | operation_t op, const LLString& filename, | ||
66 | U8* buffer, S32 offset, S32 numbytes); | ||
67 | |||
68 | S32 getBytes() | ||
69 | { | ||
70 | return mBytes; | ||
71 | } | ||
72 | S32 getBytesRead() | ||
73 | { | ||
74 | return mBytesRead; | ||
75 | } | ||
76 | S32 getOperation() | ||
77 | { | ||
78 | return mOperation; | ||
79 | } | ||
80 | U8* getBuffer() | ||
81 | { | ||
82 | return mBuffer; | ||
83 | } | ||
84 | const LLString& getFilename() | ||
85 | { | ||
86 | return mFileName; | ||
87 | } | ||
88 | |||
89 | /*virtual*/ void finishRequest(); | ||
90 | /*virtual*/ void deleteRequest(); | ||
91 | |||
92 | bool processIO(); | ||
93 | |||
94 | private: | ||
95 | operation_t mOperation; | ||
96 | |||
97 | LLString mFileName; | ||
98 | |||
99 | U8* mBuffer; // dest for reads, source for writes, new UUID for rename | ||
100 | S32 mOffset; // offset into file, -1 = append (WRITE only) | ||
101 | S32 mBytes; // bytes to read from file, -1 = all | ||
102 | S32 mBytesRead; // bytes read from file | ||
103 | }; | ||
104 | |||
105 | //------------------------------------------------------------------------ | ||
106 | public: | ||
107 | LLLFSThread(bool threaded = TRUE, bool runalways = TRUE); | ||
108 | ~LLLFSThread(); | ||
109 | |||
110 | // Return a Request handle | ||
111 | handle_t read(const LLString& filename, | ||
112 | U8* buffer, S32 offset, S32 numbytes, U32 pri=PRIORITY_NORMAL, U32 flags = 0); | ||
113 | handle_t write(const LLString& filename, | ||
114 | U8* buffer, S32 offset, S32 numbytes, U32 flags = 0); | ||
115 | handle_t rename(const LLString& filename, const LLString& newname, U32 flags = 0); | ||
116 | handle_t remove(const LLString& filename, U32 flags = 0); | ||
117 | |||
118 | // Return number of bytes read | ||
119 | S32 readImmediate(const LLString& filename, | ||
120 | U8* buffer, S32 offset, S32 numbytes); | ||
121 | S32 writeImmediate(const LLString& filename, | ||
122 | U8* buffer, S32 offset, S32 numbytes); | ||
123 | |||
124 | static void initClass(bool local_is_threaded = TRUE, bool run_always = TRUE); // Setup sLocal | ||
125 | static S32 updateClass(U32 ms_elapsed); | ||
126 | static void cleanupClass(); // Delete sLocal | ||
127 | |||
128 | protected: | ||
129 | /*virtual*/ bool processRequest(QueuedRequest* req); | ||
130 | |||
131 | public: | ||
132 | static LLLFSThread* sLocal; // Default local file thread | ||
133 | }; | ||
134 | |||
135 | //============================================================================ | ||
136 | |||
137 | |||
138 | #endif // LL_LLLFSTHREAD_H | ||