1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Copyright (c) 2014 Samsung Electronics. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
6 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_ECORE_H_
7 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_ECORE_H_
9 #include "base/base_export.h"
10 #include "base/macros.h"
11 #include "base/message_loop/message_pump.h"
12 #include "base/synchronization/lock.h"
13 #include "base/time/time.h"
19 class BASE_EXPORT MessagePumpEcore : public MessagePump {
22 ~MessagePumpEcore() override;
24 void Run(Delegate* delegate) override;
26 void ScheduleWork() override;
27 void ScheduleDelayedWork(const TimeTicks& delayed_work_time) override;
30 static void OnWakeup(void* data, void* buffer, unsigned int nbyte);
31 static Eina_Bool OnTimerFired(void* data);
33 // We may make recursive calls to Run, so we save state that needs to be
34 // separate between them in this structure type.
38 // We use a wakeup pipe to make sure we'll get out of the ecore mainloop
39 // blocking phase when another thread has scheduled us to do some work.
40 Ecore_Pipe* wakeup_pipe_;
42 // The lock that protects access to wakeup pipe.
43 base::Lock wakeup_pipe_lock_;
45 // This is the time when we need to do delayed work.
46 TimeTicks delayed_work_time_;
48 // This is the timer that is needed to get out of ecore mainloop blocking
50 Ecore_Timer* delayed_work_timer_;
52 DISALLOW_COPY_AND_ASSIGN(MessagePumpEcore);
57 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_ECORE_H_