aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llplugin/llpluginprocesschild.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xlinden/indra/llplugin/llpluginprocesschild.h121
1 files changed, 121 insertions, 0 deletions
diff --git a/linden/indra/llplugin/llpluginprocesschild.h b/linden/indra/llplugin/llpluginprocesschild.h
new file mode 100755
index 0000000..5d643d7
--- /dev/null
+++ b/linden/indra/llplugin/llpluginprocesschild.h
@@ -0,0 +1,121 @@
1/**
2 * @file llpluginprocesschild.h
3 * @brief LLPluginProcessChild handles the child side of the external-process plugin API.
4 *
5 * @cond
6 * $LicenseInfo:firstyear=2008&license=viewergpl$
7 *
8 * Copyright (c) 2008-2010, Linden Research, Inc.
9 *
10 * Second Life Viewer Source Code
11 * The source code in this file ("Source Code") is provided by Linden Lab
12 * to you under the terms of the GNU General Public License, version 2.0
13 * ("GPL"), unless you have obtained a separate licensing agreement
14 * ("Other License"), formally executed by you and Linden Lab. Terms of
15 * the GPL can be found in doc/GPL-license.txt in this distribution, or
16 * online at http://secondlife.com/developers/opensource/gplv2
17 *
18 * There are special exceptions to the terms and conditions of the GPL as
19 * it is applied to this Source Code. View the full text of the exception
20 * in the file doc/FLOSS-exception.txt in this software distribution, or
21 * online at
22 * http://secondlife.com/developers/opensource/flossexception
23 *
24 * By copying, modifying or distributing this software, you acknowledge
25 * that you have read and understood your obligations described above,
26 * and agree to abide by those obligations.
27 *
28 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
29 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
30 * COMPLETENESS OR PERFORMANCE.
31 * $/LicenseInfo$
32 *
33 * @endcond
34 */
35
36#ifndef LL_LLPLUGINPROCESSCHILD_H
37#define LL_LLPLUGINPROCESSCHILD_H
38
39#include <queue> //imprudence
40
41#include "llpluginmessage.h"
42#include "llpluginmessagepipe.h"
43#include "llplugininstance.h"
44#include "llhost.h"
45#include "llpluginsharedmemory.h"
46
47class LLPluginInstance;
48
49class LLPluginProcessChild: public LLPluginMessagePipeOwner, public LLPluginInstanceMessageListener
50{
51 LOG_CLASS(LLPluginProcessChild);
52public:
53 LLPluginProcessChild();
54 ~LLPluginProcessChild();
55
56 void init(U32 launcher_port);
57 void idle(void);
58 void sleep(F64 seconds);
59 void pump();
60
61 // returns true if the plugin is in the steady state (processing messages)
62 bool isRunning(void);
63
64 // returns true if the plugin is unloaded or we're in an unrecoverable error state.
65 bool isDone(void);
66
67 void killSockets(void);
68
69 F64 getSleepTime(void) const { return mSleepTime; };
70
71 void sendMessageToPlugin(const LLPluginMessage &message);
72 void sendMessageToParent(const LLPluginMessage &message);
73
74 // Inherited from LLPluginMessagePipeOwner
75 /* virtual */ void receiveMessageRaw(const std::string &message);
76
77 // Inherited from LLPluginInstanceMessageListener
78 /* virtual */ void receivePluginMessage(const std::string &message);
79
80private:
81
82 enum EState
83 {
84 STATE_UNINITIALIZED,
85 STATE_INITIALIZED, // init() has been called
86 STATE_CONNECTED, // connected back to launcher
87 STATE_PLUGIN_LOADING, // plugin library needs to be loaded
88 STATE_PLUGIN_LOADED, // plugin library has been loaded
89 STATE_PLUGIN_INITIALIZING, // plugin is processing init message
90 STATE_RUNNING, // steady state (processing messages)
91 STATE_UNLOADING, // plugin has sent shutdown_response and needs to be unloaded
92 STATE_UNLOADED, // plugin has been unloaded
93 STATE_ERROR, // generic bailout state
94 STATE_DONE // state machine will sit in this state after either error or normal termination.
95 };
96 void setState(EState state);
97
98 EState mState;
99
100 LLHost mLauncherHost;
101 LLSocket::ptr_t mSocket;
102
103 std::string mPluginFile;
104
105 LLPluginInstance *mInstance;
106
107 typedef std::map<std::string, LLPluginSharedMemory*> sharedMemoryRegionsType;
108 sharedMemoryRegionsType mSharedMemoryRegions;
109
110 LLTimer mHeartbeat;
111 F64 mSleepTime;
112 F64 mCPUElapsed;
113 bool mBlockingRequest;
114 bool mBlockingResponseReceived;
115 std::queue<std::string> mMessageQueue;
116
117 void deliverQueuedMessages();
118
119};
120
121#endif // LL_LLPLUGINPROCESSCHILD_H