<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="generator" content="ExDoc v0.19.1"> <title>Kernel.ParallelCompiler – Elixir v1.7.2</title> <link rel="stylesheet" href="dist/app-240d7fc7e5.css" /> <link rel="canonical" href="https://hexdocs.pm/elixir/v1.7/Kernel.ParallelCompiler.html" /> <script src="dist/sidebar_items-cdf4e58b19.js"></script> </head> <body data-type="modules"> <script>try { if(localStorage.getItem('night-mode')) document.body.className += ' night-mode'; } catch (e) { }</script> <div class="main"> <button class="sidebar-button sidebar-toggle"> <span class="icon-menu" aria-hidden="true"></span> <span class="sr-only">Toggle Sidebar</span> </button> <button class="sidebar-button night-mode-toggle"> <span class="icon-theme" aria-hidden="true"></span> <span class="sr-only">Toggle Theme</span> </button> <section class="sidebar"> <a href="http://elixir-lang.org/docs.html" class="sidebar-projectLink"> <div class="sidebar-projectDetails"> <h1 class="sidebar-projectName"> Elixir </h1> <h2 class="sidebar-projectVersion"> v1.7.2 </h2> </div> <img src="assets/logo.png" alt="Elixir" class="sidebar-projectImage"> </a> <form class="sidebar-search" action="search.html"> <button type="submit" class="search-button"> <span class="icon-search" aria-hidden="true"></span> </button> <input name="q" type="text" id="search-list" class="search-input" placeholder="Search" aria-label="Search" autocomplete="off" /> </form> <ul class="sidebar-listNav"> <li><a id="extras-list" href="#full-list">Pages</a></li> <li><a id="modules-list" href="#full-list">Modules</a></li> <li><a id="exceptions-list" href="#full-list">Exceptions</a></li> </ul> <div class="gradient"></div> <ul id="full-list" class="sidebar-fullList"></ul> </section> <section class="content"> <div class="content-outer"> <div id="content" class="content-inner"> <h1> <small class="visible-xs">Elixir v1.7.2</small> Kernel.ParallelCompiler <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/kernel/parallel_compiler.ex#L1" title="View Source" class="view-source" rel="help"> <span class="icon-code" aria-hidden="true"></span> <span class="sr-only">View Source</span> </a> </h1> <section id="moduledoc"> <p>A module responsible for compiling and requiring files in parallel.</p> </section> <section id="summary" class="details-list"> <h1 class="section-heading"> <a class="hover-link" href="#summary"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this section</span> </a> Summary </h1> <div class="summary-functions summary"> <h2> <a href="#functions">Functions</a> </h2> <div class="summary-row"> <div class="summary-signature"> <a href="#async/1">async(fun)</a> </div> <div class="summary-synopsis"><p>Starts a task for parallel compilation</p> </div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#compile/2">compile(files, options \\ [])</a> </div> <div class="summary-synopsis"><p>Compiles the given files</p> </div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#compile_to_path/3">compile_to_path(files, path, options \\ [])</a> </div> </div> <div class="summary-row"> <div class="summary-signature"> <a href="#require/2">require(files, options \\ [])</a> </div> <div class="summary-synopsis"><p>Requires the given files in parallel</p> </div> </div> </div> </section> <section id="functions" class="details-list"> <h1 class="section-heading"> <a class="hover-link" href="#functions"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this section</span> </a> Functions </h1> <div class="detail" id="async/1"> <div class="detail-header"> <a href="#async/1" class="detail-link" title="Link to this function"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this function</span> </a> <span class="signature">async(fun)</span> <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/kernel/parallel_compiler.ex#L18" class="view-source" rel="help" title="View Source"> <span class="icon-code" aria-hidden="true"></span> <span class="sr-only">View Source</span> </a> <span class="note">(since 1.6.0)</span> </div> <section class="docstring"> <p>Starts a task for parallel compilation.</p> <p>If you have a file that needs to compile other modules in parallel, the spawned processes need to be aware of the compiler environment. This function allows a developer to create a task that is aware of those environments.</p> <p>See <a href="Task.html#async/1"><code class="inline">Task.async/1</code></a> for more information. The task spawned must be always awaited on by calling <a href="Task.html#await/1"><code class="inline">Task.await/1</code></a></p> </section> </div> <div class="detail" id="compile/2"> <span id="compile/1"></span> <div class="detail-header"> <a href="#compile/2" class="detail-link" title="Link to this function"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this function</span> </a> <span class="signature">compile(files, options \\ [])</span> <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/kernel/parallel_compiler.ex#L76" class="view-source" rel="help" title="View Source"> <span class="icon-code" aria-hidden="true"></span> <span class="sr-only">View Source</span> </a> <span class="note">(since 1.6.0)</span> </div> <section class="docstring"> <p>Compiles the given files.</p> <p>Those files are compiled in parallel and can automatically detect dependencies between them. Once a dependency is found, the current file stops being compiled until the dependency is resolved.</p> <p>It returns <code class="inline">{:ok, modules, warnings}</code> or <code class="inline">{:error, errors, warnings}</code>.</p> <p>Both errors and warnings are a list of three element tuples containing the file, line and the formatted error/warning.</p> <h2 id="compile/2-options" class="section-heading"> <a href="#compile/2-options" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a> Options </h2> <ul> <li><p><code class="inline">:each_file</code> - for each file compiled, invokes the callback passing the file</p> </li> <li><p><code class="inline">:each_long_compilation</code> - for each file that takes more than a given timeout (see the <code class="inline">:long_compilation_threshold</code> option) to compile, invoke this callback passing the file as its argument</p> </li> <li><p><code class="inline">:each_module</code> - for each module compiled, invokes the callback passing the file, module and the module bytecode</p> </li> <li><p><code class="inline">:each_cycle</code> - after the given files are compiled, invokes this function that return a list with potentially more files to compile</p> </li> <li><p><code class="inline">:long_compilation_threshold</code> - the timeout (in seconds) after the <code class="inline">:each_long_compilation</code> callback is invoked; defaults to <code class="inline">15</code></p> </li> <li><p><code class="inline">:dest</code> - the destination directory for the BEAM files. When using <code class="inline">files/2</code>, this information is only used to properly annotate the BEAM files before they are loaded into memory. If you want a file to actually be written to <code class="inline">dest</code>, use <a href="#compile_to_path/3"><code class="inline">compile_to_path/3</code></a> instead.</p> </li> </ul> </section> </div> <div class="detail" id="compile_to_path/3"> <span id="compile_to_path/2"></span> <div class="detail-header"> <a href="#compile_to_path/3" class="detail-link" title="Link to this function"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this function</span> </a> <span class="signature">compile_to_path(files, path, options \\ [])</span> <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/kernel/parallel_compiler.ex#L81" class="view-source" rel="help" title="View Source"> <span class="icon-code" aria-hidden="true"></span> <span class="sr-only">View Source</span> </a> <span class="note">(since 1.6.0)</span> </div> <section class="docstring"> </section> </div> <div class="detail" id="require/2"> <span id="require/1"></span> <div class="detail-header"> <a href="#require/2" class="detail-link" title="Link to this function"> <span class="icon-link" aria-hidden="true"></span> <span class="sr-only">Link to this function</span> </a> <span class="signature">require(files, options \\ [])</span> <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/kernel/parallel_compiler.ex#L106" class="view-source" rel="help" title="View Source"> <span class="icon-code" aria-hidden="true"></span> <span class="sr-only">View Source</span> </a> <span class="note">(since 1.6.0)</span> </div> <section class="docstring"> <p>Requires the given files in parallel.</p> <p>Opposite to compile, dependencies are not attempted to be automatically solved between files.</p> <p>It returns <code class="inline">{:ok, modules, warnings}</code> or <code class="inline">{:error, errors, warnings}</code>.</p> <p>Both errors and warnings are a list of three element tuples containing the file, line and the formatted error/warning.</p> <h2 id="require/2-options" class="section-heading"> <a href="#require/2-options" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a> Options </h2> <ul> <li><p><code class="inline">:each_file</code> - for each file compiled, invokes the callback passing the file</p> </li> <li><p><code class="inline">:each_module</code> - for each module compiled, invokes the callback passing the file, module and the module bytecode</p> </li> </ul> </section> </div> </section> <footer class="footer"> <p> <span class="line"> Built using <a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" target="_blank" rel="help noopener">ExDoc</a> (v0.19.1), </span> <span class="line"> designed by <a href="https://twitter.com/dignifiedquire" target="_blank" rel="noopener" title="@dignifiedquire">Friedel Ziegelmayer</a>. </span> </p> </footer> </div> </div> </section> </div> <script src="dist/app-a0c90688fa.js"></script> </body> </html>