* @brief Gets the glib context from the tizen core handle.
* @since_tizen 9.0
*
- * @param[in] h The tizen core handle
+ * @param[in] core The tizen core handle
* @return @c the glib context on success,
* otherwise a nullptr
*/
-void *tizen_core_get_glib_context(tizen_core_h h);
+void *tizen_core_get_glib_context(tizen_core_h core);
/**
- * @brief Sets cpu boosting level of the tizen core.
+ * @brief Sets cpu boosting of the tizen core.
* @since_tizen 9.0
*
- * @param[in] h The tizen core handle
+ * @param[in] core The tizen core handle
* @param[in] level The cpu boosting level
* @return @c 0 on success,
* otherwise a negative error value
* @retval #TIZEN_CORE_ERROR_NONE Successful
* @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #TIZEN_CORE_ERROR_INVALID_CONTEXT The core is not running
- * @see tizen_core_add_source()
+ *
+ * @code
+#include <tizen_core_internal.h>
+{
+ tizen_core_h core = NULL;
+ int ret;
+
+ ret = tizen_core_find("main", &core);
+ if (ret != TIZEN_CORE_ERROR_NONE) {
+ return -1;
+ }
+
+ ret = tizen_core_set_cpu_boosting(core, TIZEN_CORE_CPU_BOOSTING_LEVEL_STRONG);
+ if (ret != TIZEN_CORE_ERROR_NONE) {
+ return -1;
+ }
+
+ return 0;
+}
+ * @endcode
+ * @see tizen_core_clear_cpu_boosting()
+ */
+int tizen_core_set_cpu_boosting(tizen_core_h core,
+ tizen_core_cpu_boosting_level_e level);
+
+/**
+ * @brief Clears cpu boosting of the tizen core.
+ * @since_tizen 9.0
+ *
+ * @param[in] core The tizen core handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #TIZEN_CORE_ERROR_NONE Successful
+ * @retval #TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TIZEN_CORE_ERROR_INVALID_CONTEXT The core is not running
+ *
+ * @code
+#include <tizen_core_internal.h>
+{
+ tizen_core_h core = NULL;
+ int ret;
+
+ ret = tizen_core_find("main", &core);
+ if (ret != TIZEN_CORE_ERROR_NONE) {
+ return -1;
+ }
+
+ ret = tizen_core_clear_cpu_boosting(core);
+ if (ret != TIZEN_CORE_ERROR_NONE) {
+ return -1;
+ }
+
+ return 0;
+}
+ * @endcode
+ * @see tizen_core_set_cpu_boosting()
*/
-int tizen_core_set_cpu_boosting_level(tizen_core_h h,
- tizen_core_cpu_boosting_level_e level);
+int tizen_core_clear_cpu_boosting(tizen_core_h core);
#ifdef __cplusplus
}
return TIZEN_CORE_ERROR_NONE;
}
-API int tizen_core_set_cpu_boosting_level(
+API int tizen_core_set_cpu_boosting(
tizen_core_h core, tizen_core_cpu_boosting_level_e level) {
if (core == nullptr) {
_E("Invalid parameter");
}
auto* task = static_cast<tizen_base::tizen_core::Task*>(core);
- if (!task->SetCpuBoostingLevel(level))
+ if (!task->SetCpuBoosting(level))
+ return TIZEN_CORE_ERROR_INVALID_CONTEXT;
+
+ return TIZEN_CORE_ERROR_NONE;
+}
+
+API int tizen_core_clear_cpu_boosting(tizen_core_h core) {
+ if (core == nullptr) {
+ _E("Invalid parameter");
+ return TIZEN_CORE_ERROR_INVALID_PARAMETER;
+ }
+
+ auto* task = static_cast<tizen_base::tizen_core::Task*>(core);
+ if (!task->ClearCpuBoosting())
return TIZEN_CORE_ERROR_INVALID_CONTEXT;
return TIZEN_CORE_ERROR_NONE;
}
}
-bool Task::SetCpuBoostingLevel(tizen_core_cpu_boosting_level_e level) {
+bool Task::SetCpuBoosting(tizen_core_cpu_boosting_level_e level) {
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (tid_ == -1) {
_E("Not running yet.");
return true;
}
+bool Task::ClearCpuBoosting() {
+ std::lock_guard<std::recursive_mutex> lock(mutex_);
+ if (tid_ == -1) {
+ _E("Not running yet.");
+ return false;
+ }
+
+ resource_pid_t res_pid = {
+ .pid = 0,
+ .tid = &tid_,
+ .tid_count = 1,
+ };
+
+ int ret = resource_clear_cpu_boosting(res_pid);
+ if (ret != 0) {
+ _E("Failed to set cpu boosting. ret(%d)", ret);
+ return false;
+ }
+
+ _I("Clear cpu boosting");
+ cpu_boosting_level_ = TIZEN_CORE_CPU_BOOSTING_LEVEL_NONE;
+ return true;
+}
+
void Task::ThreadLoop() {
g_main_context_push_thread_default(context_->GetHandle());
g_main_loop_run(loop_);