X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fmgr%2FPyModuleRunner.h;fp=src%2Fceph%2Fsrc%2Fmgr%2FPyModuleRunner.h;h=0000000000000000000000000000000000000000;hb=7da45d65be36d36b880cc55c5036e96c24b53f00;hp=cb51df3eaaff1132726aa0672612a916fa095ff0;hpb=691462d09d0987b47e112d6ee8740375df3c51b2;p=stor4nfv.git diff --git a/src/ceph/src/mgr/PyModuleRunner.h b/src/ceph/src/mgr/PyModuleRunner.h deleted file mode 100644 index cb51df3..0000000 --- a/src/ceph/src/mgr/PyModuleRunner.h +++ /dev/null @@ -1,76 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2016 John Spray - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software - * Foundation. See file COPYING. - */ - - -#pragma once - -#include "common/Thread.h" -#include "mgr/Gil.h" - -/** - * Implement the pattern of calling serve() on a module in a thread, - * until shutdown() is called. - */ -class PyModuleRunner -{ -protected: - const std::string module_name; - - // Passed in by whoever loaded our python module and looked up - // the symbols in it. - PyObject *pClass = nullptr; - - // Passed in by whoever created our subinterpreter for us - SafeThreadState pMyThreadState = nullptr; - - // Populated when we construct our instance of pClass in load() - PyObject *pClassInstance = nullptr; - - class PyModuleRunnerThread : public Thread - { - PyModuleRunner *mod; - - public: - PyModuleRunnerThread(PyModuleRunner *mod_) - : mod(mod_) {} - - void *entry() override; - }; - -public: - int serve(); - void shutdown(); - void log(int level, const std::string &record); - - PyModuleRunner( - const std::string &module_name_, - PyObject *pClass_, - const SafeThreadState &pMyThreadState_) - : - module_name(module_name_), - pClass(pClass_), pMyThreadState(pMyThreadState_), - thread(this) - { - assert(pClass != nullptr); - assert(pMyThreadState.ts != nullptr); - assert(!module_name.empty()); - } - - ~PyModuleRunner(); - - PyModuleRunnerThread thread; - - std::string const &get_name() const { return module_name; } -}; - -