diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llvfs/lllfsthread.h | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/linden/indra/llvfs/lllfsthread.h b/linden/indra/llvfs/lllfsthread.h index 8af66b1..06c53aa 100644 --- a/linden/indra/llvfs/lllfsthread.h +++ b/linden/indra/llvfs/lllfsthread.h | |||
@@ -55,15 +55,24 @@ public: | |||
55 | //------------------------------------------------------------------------ | 55 | //------------------------------------------------------------------------ |
56 | public: | 56 | public: |
57 | 57 | ||
58 | class Responder : public LLThreadSafeRefCount | ||
59 | { | ||
60 | public: | ||
61 | virtual ~Responder(); | ||
62 | virtual void completed(S32 bytes) = 0; | ||
63 | }; | ||
64 | |||
58 | class Request : public QueuedRequest | 65 | class Request : public QueuedRequest |
59 | { | 66 | { |
60 | protected: | 67 | protected: |
61 | ~Request() {}; // use deleteRequest() | 68 | virtual ~Request(); // use deleteRequest() |
62 | 69 | ||
63 | public: | 70 | public: |
64 | Request(handle_t handle, U32 priority, U32 flags, | 71 | Request(LLLFSThread* thread, |
72 | handle_t handle, U32 priority, | ||
65 | operation_t op, const LLString& filename, | 73 | operation_t op, const LLString& filename, |
66 | U8* buffer, S32 offset, S32 numbytes); | 74 | U8* buffer, S32 offset, S32 numbytes, |
75 | Responder* responder); | ||
67 | 76 | ||
68 | S32 getBytes() | 77 | S32 getBytes() |
69 | { | 78 | { |
@@ -86,12 +95,12 @@ public: | |||
86 | return mFileName; | 95 | return mFileName; |
87 | } | 96 | } |
88 | 97 | ||
89 | /*virtual*/ void finishRequest(); | 98 | /*virtual*/ bool processRequest(); |
99 | /*virtual*/ void finishRequest(bool completed); | ||
90 | /*virtual*/ void deleteRequest(); | 100 | /*virtual*/ void deleteRequest(); |
91 | |||
92 | bool processIO(); | ||
93 | 101 | ||
94 | private: | 102 | private: |
103 | LLLFSThread* mThread; | ||
95 | operation_t mOperation; | 104 | operation_t mOperation; |
96 | 105 | ||
97 | LLString mFileName; | 106 | LLString mFileName; |
@@ -99,35 +108,36 @@ public: | |||
99 | U8* mBuffer; // dest for reads, source for writes, new UUID for rename | 108 | U8* mBuffer; // dest for reads, source for writes, new UUID for rename |
100 | S32 mOffset; // offset into file, -1 = append (WRITE only) | 109 | S32 mOffset; // offset into file, -1 = append (WRITE only) |
101 | S32 mBytes; // bytes to read from file, -1 = all | 110 | S32 mBytes; // bytes to read from file, -1 = all |
102 | S32 mBytesRead; // bytes read from file | 111 | S32 mBytesRead; // bytes read from file |
112 | |||
113 | LLPointer<Responder> mResponder; | ||
103 | }; | 114 | }; |
104 | 115 | ||
105 | //------------------------------------------------------------------------ | 116 | //------------------------------------------------------------------------ |
106 | public: | 117 | public: |
107 | LLLFSThread(bool threaded = TRUE, bool runalways = TRUE); | 118 | LLLFSThread(bool threaded = TRUE); |
108 | ~LLLFSThread(); | 119 | ~LLLFSThread(); |
109 | 120 | ||
110 | // Return a Request handle | 121 | // Return a Request handle |
111 | handle_t read(const LLString& filename, | 122 | handle_t read(const LLString& filename, /* Flawfinder: ignore */ |
112 | U8* buffer, S32 offset, S32 numbytes, U32 pri=PRIORITY_NORMAL, U32 flags = 0); | 123 | U8* buffer, S32 offset, S32 numbytes, |
124 | Responder* responder, U32 pri=0); | ||
113 | handle_t write(const LLString& filename, | 125 | handle_t write(const LLString& filename, |
114 | U8* buffer, S32 offset, S32 numbytes, U32 flags = 0); | 126 | U8* buffer, S32 offset, S32 numbytes, |
115 | handle_t rename(const LLString& filename, const LLString& newname, U32 flags = 0); | 127 | Responder* responder, U32 pri=0); |
116 | handle_t remove(const LLString& filename, U32 flags = 0); | ||
117 | 128 | ||
118 | // Return number of bytes read | 129 | // Misc |
119 | S32 readImmediate(const LLString& filename, | 130 | U32 priorityCounter() { return mPriorityCounter-- & PRIORITY_LOWBITS; } // Use to order IO operations |
120 | U8* buffer, S32 offset, S32 numbytes); | 131 | |
121 | S32 writeImmediate(const LLString& filename, | 132 | // static initializers |
122 | U8* buffer, S32 offset, S32 numbytes); | 133 | static void initClass(bool local_is_threaded = TRUE); // Setup sLocal |
123 | |||
124 | static void initClass(bool local_is_threaded = TRUE, bool run_always = TRUE); // Setup sLocal | ||
125 | static S32 updateClass(U32 ms_elapsed); | 134 | static S32 updateClass(U32 ms_elapsed); |
126 | static void cleanupClass(); // Delete sLocal | 135 | static void cleanupClass(); // Delete sLocal |
127 | 136 | ||
128 | protected: | 137 | |
129 | /*virtual*/ bool processRequest(QueuedRequest* req); | 138 | private: |
130 | 139 | U32 mPriorityCounter; | |
140 | |||
131 | public: | 141 | public: |
132 | static LLLFSThread* sLocal; // Default local file thread | 142 | static LLLFSThread* sLocal; // Default local file thread |
133 | }; | 143 | }; |