To check whether the EventBroker object is attached or not, the flag is added.
Change-Id: I53d9ba060c3283f12a7b400ae4b9ea9b24b417d8
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
bool Empty() const { return queue_.IsEmpty(); }
+ void SetAttached(bool attached) { attached_ = attached; }
+
+ bool IsAttached() const { return attached_; }
+
private:
+ bool attached_ = false;
std::list<std::shared_ptr<EventHandler<T>>> handlers_;
SharedQueue<std::shared_ptr<EventObject<T>>> queue_;
};
return TIZEN_CORE_ERROR_INVALID_PARAMETER;
}
- auto* task = static_cast<tizen_base::tizen_core::Task*>(core);
auto* broker =
static_cast<tizen_base::tizen_core::event::EventBroker<void*>*>(event);
+ if (broker->IsAttached()) {
+ _E("Already attached. event=%p", event);
+ return TIZEN_CORE_ERROR_INVALID_PARAMETER;
+ }
+
+ auto* task = static_cast<tizen_base::tizen_core::Task*>(core);
auto event_source = task->AddEvent(
std::shared_ptr<tizen_base::tizen_core::event::EventBroker<void*>>(
broker));
auto* broker =
static_cast<tizen_base::tizen_core::event::EventBroker<void*>*>(event);
+ if (broker->IsAttached()) {
+ _E("Event(%p) is attached to a source", event);
+ return TIZEN_CORE_ERROR_INVALID_PARAMETER;
+ }
+
delete broker;
return TIZEN_CORE_ERROR_NONE;
}
public:
EventSource(std::shared_ptr<Task> task,
std::shared_ptr<event::EventBroker<T>> broker)
- : Source(nullptr), task_(std::move(task)), broker_(std::move(broker)) {}
+ : Source(nullptr), task_(std::move(task)), broker_(std::move(broker)) {
+ broker_->SetAttached(true);
+ }
void Emit(std::shared_ptr<event::EventObject<T>> object) {
broker_->Emit(std::move(object));