Commit 9e4b6433 authored by jinwoo7.song@samsung.com's avatar jinwoo7.song@samsung.com
Browse files

[EFL][WK2] Use std::function in the rest of EFL's WorkQueue implementation

https://bugs.webkit.org/show_bug.cgi?id=127397

Reviewed by Anders Carlsson.

Move to using std::function and move semantics in WorkQueue::registerSocketEventHandler
and DispatchQueue::setSocketEventHandler.

* Platform/IPC/unix/ConnectionUnix.cpp:
(IPC::Connection::open):
* Platform/WorkQueue.h:
* Platform/efl/DispatchQueueEfl.cpp:
(DispatchQueue::setSocketEventHandler):
* Platform/efl/DispatchQueueEfl.h:
* Platform/efl/WorkQueueEfl.cpp:
(WorkQueue::registerSocketEventHandler):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@162511 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3de29efe
2014-01-22 Jinwoo Song <jinwoo7.song@samsung.com>
[EFL][WK2] Use std::function in the rest of EFL's WorkQueue implementation
https://bugs.webkit.org/show_bug.cgi?id=127397
Reviewed by Anders Carlsson.
Move to using std::function and move semantics in WorkQueue::registerSocketEventHandler
and DispatchQueue::setSocketEventHandler.
* Platform/IPC/unix/ConnectionUnix.cpp:
(IPC::Connection::open):
* Platform/WorkQueue.h:
* Platform/efl/DispatchQueueEfl.cpp:
(DispatchQueue::setSocketEventHandler):
* Platform/efl/DispatchQueueEfl.h:
* Platform/efl/WorkQueueEfl.cpp:
(WorkQueue::registerSocketEventHandler):
2014-01-21 Tim Horton <timothy_horton@apple.com> 2014-01-21 Tim Horton <timothy_horton@apple.com>
   
[wk2] De-.get()ify receivers of Objective-C messages [wk2] De-.get()ify receivers of Objective-C messages
......
...@@ -397,7 +397,11 @@ bool Connection::open() ...@@ -397,7 +397,11 @@ bool Connection::open()
protector->connectionDidClose(); protector->connectionDidClose();
}); });
#elif PLATFORM(EFL) #elif PLATFORM(EFL)
m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, WTF::bind(&Connection::readyReadHandler, this)); RefPtr<Connection> protector(this);
m_connectionQueue->registerSocketEventHandler(m_socketDescriptor,
[protector] {
protector->readyReadHandler();
});
#endif #endif
// Schedule a call to readyReadHandler. Data may have arrived before installation of the signal // Schedule a call to readyReadHandler. Data may have arrived before installation of the signal
......
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
void registerSocketEventHandler(int, std::function<void ()>, std::function<void ()>); void registerSocketEventHandler(int, std::function<void ()>, std::function<void ()>);
void unregisterSocketEventHandler(int); void unregisterSocketEventHandler(int);
#elif PLATFORM(EFL) #elif PLATFORM(EFL)
void registerSocketEventHandler(int, const Function<void()>&); void registerSocketEventHandler(int, std::function<void ()>);
void unregisterSocketEventHandler(int); void unregisterSocketEventHandler(int);
#endif #endif
......
...@@ -115,12 +115,12 @@ void DispatchQueue::stopThread() ...@@ -115,12 +115,12 @@ void DispatchQueue::stopThread()
wakeUpThread(); wakeUpThread();
} }
void DispatchQueue::setSocketEventHandler(int fileDescriptor, const Function<void()>& function) void DispatchQueue::setSocketEventHandler(int fileDescriptor, std::function<void ()> function)
{ {
ASSERT(m_socketDescriptor == invalidSocketDescriptor); ASSERT(m_socketDescriptor == invalidSocketDescriptor);
m_socketDescriptor = fileDescriptor; m_socketDescriptor = fileDescriptor;
m_socketEventHandler = function; m_socketEventHandler = std::move(function);
if (fileDescriptor > m_maxFileDescriptor) if (fileDescriptor > m_maxFileDescriptor)
m_maxFileDescriptor = fileDescriptor; m_maxFileDescriptor = fileDescriptor;
......
...@@ -42,7 +42,7 @@ public: ...@@ -42,7 +42,7 @@ public:
void dispatch(std::unique_ptr<WorkItem>); void dispatch(std::unique_ptr<WorkItem>);
void dispatch(std::unique_ptr<TimerWorkItem>); void dispatch(std::unique_ptr<TimerWorkItem>);
void stopThread(); void stopThread();
void setSocketEventHandler(int, const Function<void()>&); void setSocketEventHandler(int, std::function<void ()>);
void clearSocketEventHandler(); void clearSocketEventHandler();
private: private:
...@@ -67,7 +67,7 @@ private: ...@@ -67,7 +67,7 @@ private:
bool m_isThreadRunning; bool m_isThreadRunning;
int m_socketDescriptor; int m_socketDescriptor;
Function<void()> m_socketEventHandler; std::function<void ()> m_socketEventHandler;
Vector<std::unique_ptr<WorkItem>> m_workItems; Vector<std::unique_ptr<WorkItem>> m_workItems;
Mutex m_workItemsLock; Mutex m_workItemsLock;
......
...@@ -34,12 +34,12 @@ void WorkQueue::platformInvalidate() ...@@ -34,12 +34,12 @@ void WorkQueue::platformInvalidate()
dispatchQueue->stopThread(); dispatchQueue->stopThread();
} }
void WorkQueue::registerSocketEventHandler(int fileDescriptor, const Function<void()>& function) void WorkQueue::registerSocketEventHandler(int fileDescriptor, std::function<void ()> function)
{ {
if (!m_dispatchQueue) if (!m_dispatchQueue)
return; return;
m_dispatchQueue->setSocketEventHandler(fileDescriptor, function); m_dispatchQueue->setSocketEventHandler(fileDescriptor, std::move(function));
} }
void WorkQueue::unregisterSocketEventHandler(int fileDescriptor) void WorkQueue::unregisterSocketEventHandler(int fileDescriptor)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment