Skip to content

Commit

Permalink
drop compiler.Pool and simplify tc39
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Jul 1, 2024
1 parent b2a33e9 commit dc116ab
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 105 deletions.
33 changes: 0 additions & 33 deletions js/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,36 +232,3 @@ func (c *compilationState) increaseMappingsByOne(sourceMap []byte) ([]byte, erro

return json.Marshal(m)
}

// Pool is a pool of compilers so it can be used easier in parallel tests as they have their own babel.
type Pool struct {
c chan *Compiler
}

// NewPool creates a Pool that will be using the provided logger and will preallocate (in parallel)
// the count of compilers each with their own babel.
func NewPool(logger logrus.FieldLogger, count int) *Pool {
c := &Pool{
c: make(chan *Compiler, count),
}
go func() {
for i := 0; i < count; i++ {
go func() {
co := New(logger)
c.Put(co)
}()
}
}()

return c
}

// Get a compiler from the pool.
func (c *Pool) Get() *Compiler {
return <-c.c
}

// Put a compiler back in the pool.
func (c *Pool) Put(co *Compiler) {
c.c <- co
}
Loading

0 comments on commit dc116ab

Please sign in to comment.