Skip to content

Commit

Permalink
Fix: No longer forgetting module reservations.
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed Nov 21, 2024
1 parent feb7e17 commit 51dfe6d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 47 deletions.
19 changes: 7 additions & 12 deletions stdlib/source/library/lux/compiler/meta/archive.lux
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,11 @@

[[module_has_already_been_reserved]
[module_must_be_reserved_before_it_can_be_added]
[module_is_only_reserved]]
)
[module_is_only_reserved]])

(every .public (Entry a)
(every .public (Entry it)
(Record
[#module (Module a)
[#module (Module it)
#output Output
#registry Registry]))

Expand Down Expand Up @@ -160,12 +159,10 @@

(the .public entries
(-> Archive
(List [descriptor.Module [module.ID (Entry Any)]]))
(List [descriptor.Module [module.ID (Maybe (Entry Any))]]))
(|>> nominal.as
(its #resolver)
dictionary.entries
(list.all (function (_ [module [module_id entry]])
(by maybe.monad each (|>> [module_id] [module]) entry)))))
dictionary.entries))

(the .public (find module archive)
(-> descriptor.Module Archive
Expand Down Expand Up @@ -276,10 +273,8 @@
(let [(open "/[0]") (nominal.as archive)]
(|> /#resolver
dictionary.entries
(list.all (function (_ [module [id descriptor+document]])
(when descriptor+document
{.#Some _} {.#Some [module id]}
{.#None} {.#None})))
(list#each (function (_ [module [id entry]])
[module id]))
[version configuration /#next]
(\\injection.value ..as_binary))))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,19 @@
(Dictionary unit.ID (Set unit.ID))])
(|> archive
archive.entries
(list#each (function (_ [module [module_id [_module output registry]]])
(|> registry
registry.artifacts
sequence.as_list
(list#each (function (_ [artifact dependencies])
[[module_id (its artifact.#id artifact)]
(its artifact.#mandatory? artifact)
dependencies])))))
(list#each (function (_ [module [module_id entry]])
(when entry
{.#Some [_module output registry]}
(|> registry
registry.artifacts
sequence.as_list
(list#each (function (_ [artifact dependencies])
[[module_id (its artifact.#id artifact)]
(its artifact.#mandatory? artifact)
dependencies])))

{.#None}
(list))))
list#conjoint
(list#mix (function (_ [artifact_id mandatory? dependencies]
[mandatory_dependencies
Expand Down
20 changes: 5 additions & 15 deletions stdlib/source/library/lux/compiler/program.lux
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,6 @@
(its context.#host context)
file/extension.tape_archive))

(the (cached_file_path fs full_path)
(-> (file.System Future) file.Path
[file.Path file.Path])
(<| maybe.trusted
(monad.let maybe.monad
[.let [/ (by fs delimiter)]
@ (text.last_index / full_path)
[directory file] (text.split_at @ full_path)]
(pure [directory (text.replaced_once / "" file)]))))

(expansion.let [<parameters> (these anchor expression artifact)]
(these (the (load_cache! host_fs cache_fs context)
(-> (file.System Future) (file.System Future) Context
Expand Down Expand Up @@ -296,13 +286,13 @@
(cache_path original_fs context)
(by tar.binary as cache))))

(the (with_caching it)
(the (with_cache it)
(for_any (_ <parameters>)
(-> (Platform <parameters>)
[(file.System Future) (Platform <parameters>)]))
(let [cache_fs (file.memory (by (its platform.#file_system it) delimiter))
it (revised platform.#file_system (hybrid_fs cache_fs) it)]
[cache_fs it]))
(let [cache_fs (file.memory (by (its platform.#file_system it) delimiter))]
[cache_fs
(revised platform.#file_system (hybrid_fs cache_fs) it)]))

(the (enable_output! original_fs context)
(-> (file.System Future) Context
Expand Down Expand Up @@ -339,7 +329,7 @@
..timed
(monad.let [! (try.with !)]
[.let [original_fs (its platform.#file_system platform)
[cache_fs platform] (with_caching platform)]
[cache_fs platform] (with_cache platform)]
_ (enable_output! original_fs file_context)
_ (load_cache! original_fs cache_fs file_context)
import (import.import (its platform.#file_system platform) (its cli.#libraries compilation))
Expand Down
23 changes: 11 additions & 12 deletions stdlib/source/library/lux/concurrency/stm.lux
Original file line number Diff line number Diff line change
Expand Up @@ -222,25 +222,25 @@
Tx
(stack))

(every (Commit it)
[(STM it)
(Future it)
(Resolver it)])
(every Commit
(for_some (_ it)
[(STM it)
(Future it)
(Resolver it)]))

(the pending_commits
(Atom (Rec Commits
[(Future [(for_some (_ it) (Commit it)) Commits])
(Resolver [(for_some (_ it) (Commit it)) Commits])]))
[(Future [Commit Commits])
(Resolver [Commit Commits])]))
(atom (future.future [])))

(the commit_processor_flag
(Atom Bit)
(atom false))

(the (issue_commit! commit)
(for_any (_ it)
(-> (Commit it)
(IO Any)))
(-> Commit
(IO Any))
(let [entry [commit (future.future [])]]
(monad.let [! io.monad]
[|commits|&resolve (atom.read! pending_commits)]
Expand All @@ -259,9 +259,8 @@
(again tail)))))))

(the (process_commit! commit)
(for_any (_ it)
(-> (Commit it)
(IO Any)))
(-> Commit
(IO Any))
(let [[stm_proc output resolve] commit
[finished_tx value] (stm_proc fresh_tx)]
(if (can_commit? finished_tx)
Expand Down

0 comments on commit 51dfe6d

Please sign in to comment.