# Checks if there is a dictionary in the queue, and if so the dictionary is handled automatically.
fun check_dictionary `{
- while(1) {
- NitHandleDictionary();
- }
+ NitHandleDictionary();
`}
+
+ # Infinite loop on check_dictionary
+ fun run
+ do
+ loop
+ check_dictionary
+ end
+ end
end
+
+redef interface Object
+ # Calls 'pthread_exit on current thread
+ fun exit_thread(exit_value: Int) `{
+ pthread_exit((void*) exit_value);
+ `}
+
+ # Redef of exit in order to avoid the module to crash by terminating only the Nit thread.
+ redef fun exit(exit_value: Int)
+ do
+ var dictionary = new PepperDictionary
+ dictionary["exit"] = exit_value
+ app.post_dictionary dictionary
+ exit_thread exit_value
+ end
+end
+
fun app: PnaclApp do return once new PnaclApp