Commit 783037bf authored by spiiroin's avatar spiiroin

[worker] Add interface for handling blocking tasks asynchronously. Contributes to JB#32840

MCE mainloop should stay responsive at all times, but there are
things like display power up/down ioctls that can block for hundreds
of milliseconds.

Add interface that allows such operations to be carried out asynchronously
in a worker thread.
parent fbd0e96d
......@@ -360,6 +360,16 @@ mce-wltimer.pic.o:\
mce-wltimer.h\
mce.h\
mce-worker.o:\
mce-worker.c\
mce-log.h\
mce-worker.h\
mce-worker.pic.o:\
mce-worker.c\
mce-log.h\
mce-worker.h\
mce.o:\
mce.c\
builtin-gconf.h\
......@@ -379,6 +389,7 @@ mce.o:\
mce-sensorfw.h\
mce-wakelock.h\
mce-wltimer.h\
mce-worker.h\
mce.h\
modetransition.h\
powerkey.h\
......@@ -403,6 +414,7 @@ mce.pic.o:\
mce-sensorfw.h\
mce-wakelock.h\
mce-wltimer.h\
mce-worker.h\
mce.h\
modetransition.h\
powerkey.h\
......
......@@ -282,6 +282,7 @@ MCE_CORE += mce-gconf.c
MCE_CORE += mce-hbtimer.c
MCE_CORE += mce-wltimer.c
MCE_CORE += mce-wakelock.c
MCE_CORE += mce-worker.c
MCE_CORE += event-input.c
MCE_CORE += event-switches.c
MCE_CORE += mce-hal.c
......@@ -547,6 +548,8 @@ NORMALIZE_USES_SPC =\
mce-sensorfw.h\
mce-wakelock.c\
mce-wakelock.h\
mce-worker.c\
mce-worker.h\
modetransition.h\
modules/alarm.c\
modules/audiorouting.c\
......
This diff is collapsed.
/**
* @file mce-worker.h
*
* Mode Control Entity - Offload blocking operations to a worker thread
*
* <p>
*
* Copyright (C) 2015 Jolla Ltd.
*
* <p>
*
* @author Simo Piiroinen <simo.piiroinen@jollamobile.com>
*
* mce is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* mce is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with mce. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MCE_WORKER_H_
# define MCE_WORKER_H_
# include <stdbool.h>
# ifdef __cplusplus
extern "C" {
# elif 0
} /* fool JED indentation ... */
# endif
void mce_worker_add_job (const char *context, const char *name, void *(*handle)(void *), void (*notify)(void *, void *), void *param);
void mce_worker_add_context(const char *context);
void mce_worker_rem_context(const char *context);
void mce_worker_quit (void);
bool mce_worker_init (void);
# ifdef __cplusplus
};
# endif
#endif /* MCE_WORKER_H_ */
......@@ -32,6 +32,7 @@
#include "mce-command-line.h"
#include "mce-sensorfw.h"
#include "mce-wakelock.h"
#include "mce-worker.h"
#include "tklock.h"
#include "powerkey.h"
#include "event-input.h"
......@@ -948,6 +949,10 @@ int main(int argc, char **argv)
/* Open fbdev as early as possible */
mce_fbdev_init();
/* Start worker thread */
if( !mce_worker_init() )
goto EXIT;
/* Get configuration options */
if( !mce_conf_init() ) {
mce_log(LL_CRIT,
......@@ -1074,6 +1079,7 @@ EXIT:
mce_gconf_exit();
mce_dbus_exit();
mce_conf_exit();
mce_worker_quit();
mce_fbdev_quit();
/* If the mainloop is initialised, unreference it */
......
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