mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-01 07:00:55 +00:00
nitpicker: Use signals for main loop
This commit is contained in:
parent
fa34b79b2c
commit
ab3bc1bb58
@ -657,14 +657,14 @@ class Input_handler_component : public Genode::Rpc_object<Input_handler,
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
User_state &_user_state;
|
User_state &_user_state;
|
||||||
View &_mouse_cursor;
|
View &_mouse_cursor;
|
||||||
Area const _mouse_size;
|
Area const _mouse_size;
|
||||||
Flush_merger &_flush_merger;
|
Flush_merger &_flush_merger;
|
||||||
Input::Session &_input;
|
Input::Session &_input;
|
||||||
Input::Event *_ev_buf;
|
Input::Event *_ev_buf;
|
||||||
Framebuffer::Session &_framebuffer;
|
Framebuffer::Session &_framebuffer;
|
||||||
Timer::Session &_timer;
|
Genode::Signal_receiver &_sig_rec;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -675,13 +675,13 @@ class Input_handler_component : public Genode::Rpc_object<Input_handler,
|
|||||||
Area mouse_size, Flush_merger &flush_merger,
|
Area mouse_size, Flush_merger &flush_merger,
|
||||||
Input::Session &input,
|
Input::Session &input,
|
||||||
Framebuffer::Session &framebuffer,
|
Framebuffer::Session &framebuffer,
|
||||||
Timer::Session &timer)
|
Genode::Signal_receiver &sig_rec)
|
||||||
:
|
:
|
||||||
_user_state(user_state), _mouse_cursor(mouse_cursor),
|
_user_state(user_state), _mouse_cursor(mouse_cursor),
|
||||||
_mouse_size(mouse_size), _flush_merger(flush_merger),
|
_mouse_size(mouse_size), _flush_merger(flush_merger),
|
||||||
_input(input),
|
_input(input),
|
||||||
_ev_buf(Genode::env()->rm_session()->attach(_input.dataspace())),
|
_ev_buf(Genode::env()->rm_session()->attach(_input.dataspace())),
|
||||||
_framebuffer(framebuffer), _timer(timer)
|
_framebuffer(framebuffer), _sig_rec(sig_rec)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -786,12 +786,12 @@ class Input_handler_component : public Genode::Rpc_object<Input_handler,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* In kill mode, we never leave the dispatch function to block
|
* In kill mode, we never leave the dispatch function to block
|
||||||
* RPC calls from Nitpicker clients. We sleep here to make the
|
* RPC calls from Nitpicker clients. We block for signals here
|
||||||
* spinning for the end of the kill mode less painful for all
|
* to make the spinning for the end of the kill mode less
|
||||||
* non-blocked processes.
|
* painful for all non-blocked processes.
|
||||||
*/
|
*/
|
||||||
if (_user_state.kill())
|
if (_user_state.kill())
|
||||||
_timer.msleep(10);
|
_sig_rec.wait_for_signal();
|
||||||
|
|
||||||
} while (_user_state.kill());
|
} while (_user_state.kill());
|
||||||
}
|
}
|
||||||
@ -887,7 +887,6 @@ int main(int argc, char **argv)
|
|||||||
/*
|
/*
|
||||||
* Sessions to the required external services
|
* Sessions to the required external services
|
||||||
*/
|
*/
|
||||||
static Timer::Connection timer;
|
|
||||||
static Framebuffer::Connection framebuffer;
|
static Framebuffer::Connection framebuffer;
|
||||||
static Input::Connection input;
|
static Input::Connection input;
|
||||||
static Cap_connection cap;
|
static Cap_connection cap;
|
||||||
@ -951,7 +950,6 @@ int main(int argc, char **argv)
|
|||||||
/*
|
/*
|
||||||
* Initialize Nitpicker root interface
|
* Initialize Nitpicker root interface
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Sliced_heap sliced_heap(env()->ram_session(), env()->rm_session());
|
Sliced_heap sliced_heap(env()->ram_session(), env()->rm_session());
|
||||||
|
|
||||||
static Nitpicker::Root<PT> np_root(session_list, global_keys,
|
static Nitpicker::Root<PT> np_root(session_list, global_keys,
|
||||||
@ -962,6 +960,16 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
env()->parent()->announce(ep.manage(&np_root));
|
env()->parent()->announce(ep.manage(&np_root));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Schedule periodic timer signals every 10 milliseconds
|
||||||
|
*/
|
||||||
|
static Timer::Connection timer;
|
||||||
|
static Signal_receiver sig_rec;
|
||||||
|
Signal_context timer_sig_ctx;
|
||||||
|
|
||||||
|
timer.sigh(sig_rec.manage(&timer_sig_ctx));
|
||||||
|
timer.trigger_periodic(10*1000);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize input handling
|
* Initialize input handling
|
||||||
*
|
*
|
||||||
@ -972,17 +980,13 @@ int main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
static Input_handler_component
|
static Input_handler_component
|
||||||
input_handler(user_state, mouse_cursor, mouse_size,
|
input_handler(user_state, mouse_cursor, mouse_size,
|
||||||
screen, input, framebuffer, timer);
|
screen, input, framebuffer, sig_rec);
|
||||||
|
|
||||||
Capability<Input_handler> input_handler_cap = ep.manage(&input_handler);
|
Capability<Input_handler> input_handler_cap = ep.manage(&input_handler);
|
||||||
|
|
||||||
/* start periodic mode of operation */
|
for (;;) {
|
||||||
static Msgbuf<256> ih_snd_msg, ih_rcv_msg;
|
sig_rec.wait_for_signal();
|
||||||
Ipc_client input_handler_client(input_handler_cap, &ih_snd_msg, &ih_rcv_msg);
|
input_handler_cap.call<Input_handler::Rpc_do_input_handling>();
|
||||||
while (1) {
|
|
||||||
timer.msleep(10);
|
|
||||||
input_handler_client << 0 << IPC_CALL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep_forever();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user