#ifndef __TclThread_h_ #define __TclThread_h_ #include "../../shared/ThreadClass.h" class Tcl_Interp; class TclSupportDataNode; class DataNodeLink; // This should be created in the data node thread. This will not be the data // node thread. The idea is that you might have N tcl threads and one data // node thread. class TclThread : private ThreadClass { private: class ScriptRequest : public Request { public: ScriptRequest() : Request(NULL) { } std::string script; std::string notes; }; class ExternalScriptRequest : public Request { public: ExternalScriptRequest(SocketInfo *s) : Request(s) { } std::string script; ExternalRequest::MessageId returnMsgId; }; enum { mtTclCommand, mtExecuteScript, mtQuit }; SelectableRequestQueue _incoming; Tcl_Interp *_interp; TclSupportDataNode *_supportDataNode; DataNodeLink *_supportDataNodeLink; protected: void threadFunction(); public: TclThread(); ~TclThread(); // This is thread safe. This will execute the script. If there is an error // it will be reported to the log. The notes are only used for reporting // errors. void executeScript(std::string const &script, std::string const ¬es = "TclThread::executeScript()"); // This is thread safe. The results, success or failure, are sent to the // given stocket with the given message id. void externalScript(std::string const &script, SocketInfo *socket, ExternalRequest::MessageId returnMsgId); // These should really be private. void requestL1Data(std::string const &symbol); void stopL1Data(std::string const &symbol); void requestCandleData(std::string const &symbol, int minutes); void stopCandleData(std::string const &symbol, int minutes); }; #endif