File tree Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ require "bundler/setup"
5
5
require "pgpm"
6
6
require "dry/cli"
7
7
require "parallel"
8
+ require "etc"
8
9
9
10
module Pgpm
10
11
module CLI
@@ -48,7 +49,7 @@ module Pgpm
48
49
49
50
# puts "There is no build support for OS distribution `#{os}`"
50
51
# exit(1)
51
- pkgs = Parallel . flat_map ( packages ) do |package |
52
+ pkgs = Parallel . flat_map ( packages , in_threads : Etc . nprocessors ) do |package |
52
53
name , version = package . split ( "@" )
53
54
version ||= :latest
54
55
p = Pgpm ::Package [ name ]
@@ -122,7 +123,7 @@ module Pgpm
122
123
Pgpm . load_packages ( pkgdir )
123
124
124
125
query_regexp = Regexp . new ( query , "i" )
125
- Parallel . filter_map ( Pgpm ::Package ) do |p |
126
+ Parallel . filter_map ( Pgpm ::Package , in_threads : Etc . nprocessors ) do |p |
126
127
next if p . contrib?
127
128
128
129
matches = p . all_searchable_texts . any? do |t |
Original file line number Diff line number Diff line change @@ -7,20 +7,27 @@ module Omnigres
7
7
class ExtensionDiscovery
8
8
@@extensions = { }
9
9
@@git_revisions = { }
10
+ @mutex = Mutex . new
11
+
12
+ class << self
13
+ attr_reader :mutex # Expose a class-level reader for the mutex
14
+ end
10
15
11
16
def initialize ( revision : nil , path : nil )
12
17
return if @@extensions [ revision ]
13
18
14
19
suffix = revision ? "-#{ revision } " : nil
15
20
path ||= Pgpm ::Cache . directory . join ( "omnigres#{ suffix } " )
16
- git =
17
- if File . directory? ( path )
18
- ::Git . open ( path )
19
- else
20
- ::Git . clone ( "https://github.com/omnigres/omnigres" , path )
21
- end
22
- git . checkout ( revision ) if revision
23
- @git = git
21
+ self . class . mutex . synchronize do
22
+ git =
23
+ if File . directory? ( path )
24
+ ::Git . open ( path )
25
+ else
26
+ ::Git . clone ( "https://github.com/omnigres/omnigres" , path )
27
+ end
28
+ git . checkout ( revision ) if revision
29
+ @git = git
30
+ end
24
31
end
25
32
26
33
attr_reader :git
You can’t perform that action at this time.
0 commit comments