diff options
Diffstat (limited to 'src/lux/compiler/parallel.clj')
-rw-r--r-- | src/lux/compiler/parallel.clj | 56 |
1 files changed, 12 insertions, 44 deletions
diff --git a/src/lux/compiler/parallel.clj b/src/lux/compiler/parallel.clj index 42598ef7e..453033287 100644 --- a/src/lux/compiler/parallel.clj +++ b/src/lux/compiler/parallel.clj @@ -9,9 +9,7 @@ [template :refer [do-template]]) clojure.core.match clojure.core.match.array - (lux [base :as & :refer [|let |do return* return fail fail* |case]]) - (lux.analyser [base :as &a] - [module :as &a-module]))) + (lux [base :as & :refer [|let |do return* return fail fail* |case]]))) ;; [Utils] (def ^:private !state! (ref {})) @@ -21,36 +19,22 @@ (return* compiler compiler))) (defn ^:private compilation-task [compile-module* module-name] - (|do [current-module &/get-module-name - compiler get-compiler + (|do [compiler get-compiler :let [[task new?] (dosync (if-let [existing-task (get @!state! module-name)] (&/T [existing-task false]) (let [new-task (promise)] (do (alter !state! assoc module-name new-task) (&/T [new-task true]))))) - result (when new? - (doto (new Thread - (fn [] - (do ;; (&/|log! 'THREAD-START [current-module module-name]) - (|case (&/run-state (|do [_ (compile-module* module-name) - _module (&a-module/find-module module-name) - ;; :let [_ (&/|log! "Just compiled:" module-name (->> _module - ;; (&/get$ &a-module/$defs) - ;; &/|length))] - ] - (return nil)) - compiler) - (&/$Right post-compiler _) - (do ;; (&/|log! 'FINISHED 'compilation-task [current-module module-name] post-compiler) - (deliver task post-compiler)) + _ (when new? + (.start (new Thread + (fn [] + (|case (&/run-state (compile-module* module-name) + compiler) + (&/$Right post-compiler _) + (deliver task post-compiler) - (&/$Left ?error) - (do (&/|log! ?error) - ;; (System/exit 1) - ))))) - (.start))) - ;; _ (&/|log! 'parallel-compilation [current-module module-name] new? result) - ]] + (&/$Left ?error) + (&/|log! ?error))))))]] (return task))) ;; [Exports] @@ -61,20 +45,4 @@ (defn parallel-compilation [compile-module*] (fn [module-name] - (|do [;; pre get-compiler - ?async (compilation-task compile-module* module-name) - ;; post get-compiler - ;; post* (set-compiler (merge-compilers post pre)) - ;; TODO: Some type-vars in the typing environment stay in - ;; the environment forever, making type-checking slower. - ;; The merging process for modules more-or-less "fixes" the - ;; problem by resetting the typing enviroment, but ideally - ;; those type-vars shouldn't survive in the first place. - ;; MUST FIX - ;; :let [_ (prn 'parallel-compilation module-name - ;; 'PRE (->> pre (&/get$ &/$type-vars) (&/get$ &/$mappings) &/|length) - ;; 'POST (->> post (&/get$ &/$type-vars) (&/get$ &/$mappings) &/|length) - ;; 'POST* (->> post* (&/get$ &/$type-vars) (&/get$ &/$mappings) &/|length))] - ] - (return ?async) - ))) + (compilation-task compile-module* module-name))) |