GSource* Source::GetHandle() const { return handle_; }
-void Source::RefSelf() { if (!self_) self_ = shared_from_this(); }
+void Source::RefSelf() {
+ std::lock_guard<std::recursive_mutex> lock(GetMutex());
+ if (!self_) self_ = shared_from_this();
+}
-void Source::UnrefSelf() { self_.reset(); }
+void Source::UnrefSelf() {
+ std::lock_guard<std::recursive_mutex> lock(GetMutex());
+ self_.reset();
+}
void Source::SetPriority(int priority) {
g_source_set_priority(handle_, priority);
}
+std::recursive_mutex& Source::GetMutex() const { return mutex_; }
+
// LCOV_EXCL_START
-bool Source::OnSourcePrepare(int* timeout) { return false; }
+bool Source::OnSourcePrepare(int* timeout) {return false; }
bool Source::OnSourceCheck() { return false; }
if (source == nullptr)
return FALSE;
+ std::lock_guard<std::recursive_mutex> lock(source->GetMutex());
return source->OnSourcePrepare(timeout);
}
if (source == nullptr)
return FALSE;
+ std::lock_guard<std::recursive_mutex> lock(source->GetMutex());
return source->OnSourceCheck();
}
if (source == nullptr)
return FALSE;
+ std::lock_guard<std::recursive_mutex> lock(source->GetMutex());
return source->OnSourceDispatch();
}
if (source == nullptr)
return;
+ std::lock_guard<std::recursive_mutex> lock(source->GetMutex());
source->OnSourceFinalize();
}
// LCOV_EXCL_STOP
#include <list>
#include <memory>
+#include <mutex>
#include "tizen-core/context.h"
#include "tizen-core/interface_source.h"
static gboolean SourceDispatchFunc(GSource* gsource, GSourceFunc callback,
gpointer user_data);
static void SourceFinalizeFunc(GSource* gsource);
+ std::recursive_mutex& GetMutex() const;
private:
GSource* handle_ = nullptr;
bool attached_ = false;
std::shared_ptr<Source> self_;
std::list<std::shared_ptr<PollFd>> poll_fds_;
+ mutable std::recursive_mutex mutex_;
};
} // namespace tizen_core