From: James Sedgwick Date: Wed, 18 Oct 2017 03:21:36 +0000 (-0700) Subject: move python/NotificationQueueExecutor to futures/ X-Git-Tag: v2017.10.23.00~30 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=11b73c8f4fcb5d00b030d14cb4894b6cfb199039;p=folly.git move python/NotificationQueueExecutor to futures/ Summary: as above Reviewed By: yfeldblum Differential Revision: D6076757 fbshipit-source-id: afe144129e8a0242ba6baee96a84a9084e6e2571 --- diff --git a/folly/Makefile.am b/folly/Makefile.am index ad956fb4..2e172ead 100644 --- a/folly/Makefile.am +++ b/folly/Makefile.am @@ -96,6 +96,7 @@ nobase_follyinclude_HEADERS = \ executors/IOThreadPoolExecutor.h \ executors/LifoSemMPMCQueue.h \ executors/NamedThreadFactory.h \ + executors/NotificationQueueExecutor.h \ executors/PriorityLifoSemMPMCQueue.h \ executors/PriorityThreadFactory.h \ executors/SerialExecutor.h \ diff --git a/folly/executors/NotificationQueueExecutor.h b/folly/executors/NotificationQueueExecutor.h new file mode 100644 index 00000000..3738be24 --- /dev/null +++ b/folly/executors/NotificationQueueExecutor.h @@ -0,0 +1,57 @@ +/* + * Copyright 2017-present Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include +#include +#include +#include + +namespace folly { + +class NotificationQueueExecutor : public folly::DrivableExecutor { + public: + using Func = folly::Func; + + void add(Func func) override { + queue_.putMessage(std::move(func)); + } + + int fileno() const { + return consumer_.getFd(); + } + + void drive() noexcept override { + Func func; + while (queue_.tryConsume(func)) { + try { + func(); + } catch (const std::exception& ex) { + LOG(ERROR) << "Exception thrown by NotificationQueueExecutor task." + << "Exception message: " << folly::exceptionStr(ex); + } catch (...) { + LOG(ERROR) << "Unknown Exception thrown " + << "by NotificationQueueExecutor task."; + } + } + } + + private: + folly::NotificationQueue queue_; + folly::NotificationQueue::SimpleConsumer consumer_{queue_}; +}; // NotificationQueueExecutor + +} // namespace folly diff --git a/folly/python/NotificationQueueExecutor.h b/folly/python/NotificationQueueExecutor.h deleted file mode 100644 index 7bd8f2a4..00000000 --- a/folly/python/NotificationQueueExecutor.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2017-present Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#pragma once - -#include -#include -#include -#include - -namespace folly { -namespace python { - -class NotificationQueueExecutor : public folly::DrivableExecutor { - public: - using Func = folly::Func; - - void add(Func func) override { - queue_.putMessage(std::move(func)); - } - - int fileno() const { - return consumer_.getFd(); - } - - void drive() noexcept override { - Func func; - while (queue_.tryConsume(func)) { - try { - func(); - } catch (const std::exception& ex) { - LOG(ERROR) << "Exception thrown by NotificationQueueExecutor task." - << "Exception message: " << folly::exceptionStr(ex); - } catch (...) { - LOG(ERROR) << "Unknown Exception thrown " - << "by NotificationQueueExecutor task."; - } - } - } - - private: - folly::NotificationQueue queue_; - folly::NotificationQueue::SimpleConsumer consumer_{queue_}; -}; // NotificationQueueExecutor - -} // namespace python -} // namespace folly diff --git a/folly/python/executor.pxd b/folly/python/executor.pxd index ab4c51b7..eeb8acd5 100644 --- a/folly/python/executor.pxd +++ b/folly/python/executor.pxd @@ -1,8 +1,8 @@ from libcpp.memory cimport unique_ptr from folly cimport cFollyExecutor -cdef extern from "folly/python/NotificationQueueExecutor.h" namespace "folly::python": - cdef cppclass cNotificationQueueExecutor "folly::python::NotificationQueueExecutor"(cFollyExecutor): +cdef extern from "folly/executors/NotificationQueueExecutor.h" namespace "folly": + cdef cppclass cNotificationQueueExecutor "folly::NotificationQueueExecutor"(cFollyExecutor): int fileno() void drive()