Annotation of /linden_release/linden/indra/llvfs/lllfsthread.h
Parent Directory
|
Revision Log
Revision 100 - (view) (download)
| 1 : | mjm | 57 | /** |
| 2 : | * @file lllfsthread.h | ||
| 3 : | * @brief LLLFSThread base class | ||
| 4 : | * | ||
| 5 : | * $LicenseInfo:firstyear=2000&license=viewergpl$ | ||
| 6 : | * | ||
| 7 : | mjm | 100 | * Copyright (c) 2000-2009, Linden Research, Inc. |
| 8 : | mjm | 57 | * |
| 9 : | * Second Life Viewer Source Code | ||
| 10 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 11 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 12 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 13 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 14 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 15 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 16 : | * | ||
| 17 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 18 : | * it is applied to this Source Code. View the full text of the exception | ||
| 19 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 20 : | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 21 : | * | ||
| 22 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 23 : | * that you have read and understood your obligations described above, | ||
| 24 : | * and agree to abide by those obligations. | ||
| 25 : | * | ||
| 26 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 27 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 28 : | * COMPLETENESS OR PERFORMANCE. | ||
| 29 : | * $/LicenseInfo$ | ||
| 30 : | */ | ||
| 31 : | |||
| 32 : | #ifndef LL_LLLFSTHREAD_H | ||
| 33 : | #define LL_LLLFSTHREAD_H | ||
| 34 : | |||
| 35 : | #include <queue> | ||
| 36 : | #include <string> | ||
| 37 : | #include <map> | ||
| 38 : | #include <set> | ||
| 39 : | |||
| 40 : | #include "llapr.h" | ||
| 41 : | |||
| 42 : | #include "llqueuedthread.h" | ||
| 43 : | |||
| 44 : | //============================================================================ | ||
| 45 : | // Threaded Local File System | ||
| 46 : | //============================================================================ | ||
| 47 : | |||
| 48 : | class LLLFSThread : public LLQueuedThread | ||
| 49 : | { | ||
| 50 : | //------------------------------------------------------------------------ | ||
| 51 : | public: | ||
| 52 : | enum operation_t { | ||
| 53 : | FILE_READ, | ||
| 54 : | FILE_WRITE, | ||
| 55 : | FILE_RENAME, | ||
| 56 : | FILE_REMOVE | ||
| 57 : | }; | ||
| 58 : | |||
| 59 : | //------------------------------------------------------------------------ | ||
| 60 : | public: | ||
| 61 : | |||
| 62 : | class Responder : public LLThreadSafeRefCount | ||
| 63 : | { | ||
| 64 : | protected: | ||
| 65 : | ~Responder(); | ||
| 66 : | public: | ||
| 67 : | virtual void completed(S32 bytes) = 0; | ||
| 68 : | }; | ||
| 69 : | |||
| 70 : | class Request : public QueuedRequest | ||
| 71 : | { | ||
| 72 : | protected: | ||
| 73 : | virtual ~Request(); // use deleteRequest() | ||
| 74 : | |||
| 75 : | public: | ||
| 76 : | Request(LLLFSThread* thread, | ||
| 77 : | handle_t handle, U32 priority, | ||
| 78 : | operation_t op, const std::string& filename, | ||
| 79 : | U8* buffer, S32 offset, S32 numbytes, | ||
| 80 : | Responder* responder); | ||
| 81 : | |||
| 82 : | S32 getBytes() | ||
| 83 : | { | ||
| 84 : | return mBytes; | ||
| 85 : | } | ||
| 86 : | S32 getBytesRead() | ||
| 87 : | { | ||
| 88 : | return mBytesRead; | ||
| 89 : | } | ||
| 90 : | S32 getOperation() | ||
| 91 : | { | ||
| 92 : | return mOperation; | ||
| 93 : | } | ||
| 94 : | U8* getBuffer() | ||
| 95 : | { | ||
| 96 : | return mBuffer; | ||
| 97 : | } | ||
| 98 : | const std::string& getFilename() | ||
| 99 : | { | ||
| 100 : | return mFileName; | ||
| 101 : | } | ||
| 102 : | |||
| 103 : | /*virtual*/ bool processRequest(); | ||
| 104 : | /*virtual*/ void finishRequest(bool completed); | ||
| 105 : | /*virtual*/ void deleteRequest(); | ||
| 106 : | |||
| 107 : | private: | ||
| 108 : | LLLFSThread* mThread; | ||
| 109 : | operation_t mOperation; | ||
| 110 : | |||
| 111 : | std::string mFileName; | ||
| 112 : | |||
| 113 : | U8* mBuffer; // dest for reads, source for writes, new UUID for rename | ||
| 114 : | S32 mOffset; // offset into file, -1 = append (WRITE only) | ||
| 115 : | S32 mBytes; // bytes to read from file, -1 = all | ||
| 116 : | S32 mBytesRead; // bytes read from file | ||
| 117 : | |||
| 118 : | LLPointer<Responder> mResponder; | ||
| 119 : | }; | ||
| 120 : | |||
| 121 : | //------------------------------------------------------------------------ | ||
| 122 : | public: | ||
| 123 : | LLLFSThread(bool threaded = TRUE); | ||
| 124 : | ~LLLFSThread(); | ||
| 125 : | |||
| 126 : | // Return a Request handle | ||
| 127 : | handle_t read(const std::string& filename, /* Flawfinder: ignore */ | ||
| 128 : | U8* buffer, S32 offset, S32 numbytes, | ||
| 129 : | Responder* responder, U32 pri=0); | ||
| 130 : | handle_t write(const std::string& filename, | ||
| 131 : | U8* buffer, S32 offset, S32 numbytes, | ||
| 132 : | Responder* responder, U32 pri=0); | ||
| 133 : | |||
| 134 : | // Misc | ||
| 135 : | U32 priorityCounter() { return mPriorityCounter-- & PRIORITY_LOWBITS; } // Use to order IO operations | ||
| 136 : | |||
| 137 : | // static initializers | ||
| 138 : | static void initClass(bool local_is_threaded = TRUE); // Setup sLocal | ||
| 139 : | static S32 updateClass(U32 ms_elapsed); | ||
| 140 : | static void cleanupClass(); // Delete sLocal | ||
| 141 : | |||
| 142 : | |||
| 143 : | private: | ||
| 144 : | U32 mPriorityCounter; | ||
| 145 : | |||
| 146 : | public: | ||
| 147 : | static LLLFSThread* sLocal; // Default local file thread | ||
| 148 : | }; | ||
| 149 : | |||
| 150 : | //============================================================================ | ||
| 151 : | |||
| 152 : | |||
| 153 : | #endif // LL_LLLFSTHREAD_H |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

