aboutsummaryrefslogtreecommitdiff
path: root/gd/os/handler.h
diff options
context:
space:
mode:
Diffstat (limited to 'gd/os/handler.h')
-rw-r--r--gd/os/handler.h47
1 files changed, 4 insertions, 43 deletions
diff --git a/gd/os/handler.h b/gd/os/handler.h
index 9e530bc36..d9dea0ba1 100644
--- a/gd/os/handler.h
+++ b/gd/os/handler.h
@@ -21,9 +21,7 @@
#include <mutex>
#include <queue>
-#include "common/bind.h"
#include "common/callback.h"
-#include "common/contextual_callback.h"
#include "os/thread.h"
#include "os/utils.h"
@@ -33,18 +31,18 @@ namespace os {
// A message-queue style handler for reactor-based thread to handle incoming events from different threads. When it's
// constructed, it will register a reactable on the specified thread; when it's destroyed, it will unregister itself
// from the thread.
-class Handler : public common::IPostableContext {
+class Handler {
public:
// Create and register a handler on given thread
explicit Handler(Thread* thread);
// Unregister this handler from the thread and release resource. Unhandled events will be discarded and not executed.
- virtual ~Handler();
+ ~Handler();
DISALLOW_COPY_AND_ASSIGN(Handler);
// Enqueue a closure to the queue of this handler
- virtual void Post(common::OnceClosure closure) override;
+ void Post(OnceClosure closure);
// Remove all pending events from the queue of this handler
void Clear();
@@ -52,43 +50,6 @@ class Handler : public common::IPostableContext {
// Die if the current reactable doesn't stop before the timeout. Must be called after Clear()
void WaitUntilStopped(std::chrono::milliseconds timeout);
- template <typename Functor, typename... Args>
- void Call(Functor&& functor, Args&&... args) {
- Post(common::BindOnce(std::forward<Functor>(functor), std::forward<Args>(args)...));
- }
-
- template <typename T, typename Functor, typename... Args>
- void CallOn(T* obj, Functor&& functor, Args&&... args) {
- Post(common::BindOnce(std::forward<Functor>(functor), common::Unretained(obj), std::forward<Args>(args)...));
- }
-
- template <typename Functor, typename... Args>
- common::ContextualOnceCallback<common::MakeUnboundRunType<Functor, Args...>> BindOnce(
- Functor&& functor, Args&&... args) {
- return common::ContextualOnceCallback<common::MakeUnboundRunType<Functor, Args...>>(
- common::BindOnce(std::forward<Functor>(functor), std::forward<Args>(args)...), this);
- }
-
- template <typename Functor, typename T, typename... Args>
- common::ContextualOnceCallback<common::MakeUnboundRunType<Functor, T, Args...>> BindOnceOn(
- T* obj, Functor&& functor, Args&&... args) {
- return common::ContextualOnceCallback<common::MakeUnboundRunType<Functor, T, Args...>>(
- common::BindOnce(std::forward<Functor>(functor), common::Unretained(obj), std::forward<Args>(args)...), this);
- }
-
- template <typename Functor, typename... Args>
- common::ContextualCallback<common::MakeUnboundRunType<Functor, Args...>> Bind(Functor&& functor, Args&&... args) {
- return common::ContextualCallback<common::MakeUnboundRunType<Functor, Args...>>(
- common::Bind(std::forward<Functor>(functor), std::forward<Args>(args)...), this);
- }
-
- template <typename Functor, typename T, typename... Args>
- common::ContextualCallback<common::MakeUnboundRunType<Functor, T, Args...>> BindOn(
- T* obj, Functor&& functor, Args&&... args) {
- return common::ContextualCallback<common::MakeUnboundRunType<Functor, T, Args...>>(
- common::Bind(std::forward<Functor>(functor), common::Unretained(obj), std::forward<Args>(args)...), this);
- }
-
template <typename T>
friend class Queue;
@@ -100,7 +61,7 @@ class Handler : public common::IPostableContext {
inline bool was_cleared() const {
return tasks_ == nullptr;
};
- std::queue<common::OnceClosure>* tasks_;
+ std::queue<OnceClosure>* tasks_;
Thread* thread_;
int fd_;
Reactor::Reactable* reactable_;