]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
add --thread option to enable multithreading support
authorJuerg Billeter <j@bitron.ch>
Tue, 10 Jul 2007 07:46:04 +0000 (07:46 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Tue, 10 Jul 2007 07:46:04 +0000 (07:46 +0000)
2007-07-10  Juerg Billeter  <j@bitron.ch>

* vala/valacodecontext.vala, gobject/valaccodecompiler.vala,
  gobject/valacodegeneratormethod.vala, compiler/valacompiler.vala:
  add --thread option to enable multithreading support

svn path=/trunk/; revision=340

ChangeLog
compiler/valacompiler.vala
gobject/valaccodecompiler.vala
gobject/valacodegeneratormethod.vala
vala/valacodecontext.vala

index abb7abe46544fb583b752e06c667e1def44b768d..12afd726cc2b632d22e6cdee50fdfe60d97adb74 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-07-10  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valacodecontext.vala, gobject/valaccodecompiler.vala,
+         gobject/valacodegeneratormethod.vala, compiler/valacompiler.vala:
+         add --thread option to enable multithreading support
+
 2007-07-10  Jürg Billeter  <j@bitron.ch>
 
        * gobject/valaccodecompiler.vala: always use gobject-2.0
index e0381ed3cb057dc6b058ecc42531d62d9460979b..f63377d04ed42a3dee7f3700de53e93106d87e16 100644 (file)
@@ -38,6 +38,7 @@ class Vala.Compiler {
        static bool compile_only;
        static string output;
        static bool debug;
+       static bool thread;
        static int optlevel;
        static bool disable_assert;
        static bool enable_checking;
@@ -55,6 +56,7 @@ class Vala.Compiler {
                { "compile", 'c', 0, OptionArg.NONE, ref compile_only, "Compile but do not link", null },
                { "output", 'o', 0, OptionArg.FILENAME, out output, "Place output in file FILE", "FILE" },
                { "debug", 'g', 0, OptionArg.NONE, ref debug, "Produce debug information", null },
+               { "thread", 0, 0, OptionArg.NONE, ref thread, "Enable multithreading support", null },
                { "optimize", 'O', 0, OptionArg.INT, ref optlevel, "Optimization level", "OPTLEVEL" },
                { "disable-assert", 0, 0, OptionArg.NONE, ref disable_assert, "Disable assertions", null },
                { "enable-checking", 0, 0, OptionArg.NONE, ref enable_checking, "Enable run-time checks", null },
@@ -152,6 +154,7 @@ class Vala.Compiler {
                context.compile_only = compile_only;
                context.output = output;
                context.debug = debug;
+               context.thread = thread;
                context.optlevel = optlevel;
 
                /* default package */
index cb10ce17a8e67972210429a38d5b6db5df2eacae..9d7e2d1eddd74df91b5c1220de0ed40e020f6f62 100644 (file)
@@ -41,6 +41,9 @@ public class Vala.CCodeCompiler {
                        pc += " --libs";
                }
                pc += " gobject-2.0";
+               if (context.thread) {
+                       pc += " gthread-2.0";
+               }
                foreach (string pkg in context.get_packages ()) {
                        pc += " " + pkg;
                }
index 270e3d5b2507adcbc7125843d7eab13b60315c31..211ab3782091cfdc85df42e663861ae35d836f70 100644 (file)
@@ -311,6 +311,13 @@ public class Vala.CodeGenerator {
                        cmain.add_parameter (new CCodeFormalParameter ("argc", "int"));
                        cmain.add_parameter (new CCodeFormalParameter ("argv", "char **"));
                        var main_block = new CCodeBlock ();
+
+                       if (context.thread) {
+                               var thread_init_call = new CCodeFunctionCall (new CCodeIdentifier ("g_thread_init"));
+                               thread_init_call.add_argument (new CCodeConstant ("NULL"));
+                               main_block.add_statement (new CCodeExpressionStatement (thread_init_call)); 
+                       }
+
                        main_block.add_statement (new CCodeExpressionStatement (new CCodeFunctionCall (new CCodeIdentifier ("g_type_init"))));
                        var main_call = new CCodeFunctionCall (new CCodeIdentifier (function.name));
                        if (args_parameter) {
index 6d1271a7e2d1ac1c7e2c5f66b6167e831e8915c0..068c4eedc41e4169807127d57462ab432ed7789d 100644 (file)
@@ -74,6 +74,11 @@ public class Vala.CodeContext {
         */
        public int optlevel { get; set; }
 
+       /**
+        * Enable multithreading support.
+        */
+       public bool thread { get; set; }
+
        /**
         * Specifies the optional module initialization method.
         */