mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-15 00:43:02 +00:00
hugolib: Revert to using Page as the render chan type
Changing it to PageOutput was a mistake. You may think that the increased parallelism should be a good thing. But not so much with the increased lock contention and more complex concurrency model.
This commit is contained in:
parent
e5200ddaa4
commit
03122e51fa
2 changed files with 38 additions and 35 deletions
|
@ -25,9 +25,11 @@ type PageOutput struct {
|
||||||
outputType output.Type
|
outputType output.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPageOutput(p *Page, outputType output.Type) *PageOutput {
|
func newPageOutput(p *Page, createCopy bool, outputType output.Type) *PageOutput {
|
||||||
// TODO(bep) output avoid copy of first?
|
// TODO(bep) output avoid copy of first?
|
||||||
p = p.copy()
|
if createCopy {
|
||||||
|
p = p.copy()
|
||||||
|
}
|
||||||
return &PageOutput{Page: p, outputType: outputType}
|
return &PageOutput{Page: p, outputType: outputType}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,9 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
bp "github.com/spf13/hugo/bufferpool"
|
|
||||||
"github.com/spf13/hugo/output"
|
"github.com/spf13/hugo/output"
|
||||||
|
|
||||||
|
bp "github.com/spf13/hugo/bufferpool"
|
||||||
)
|
)
|
||||||
|
|
||||||
// renderPages renders pages each corresponding to a markdown file.
|
// renderPages renders pages each corresponding to a markdown file.
|
||||||
|
@ -29,7 +30,7 @@ import (
|
||||||
func (s *Site) renderPages() error {
|
func (s *Site) renderPages() error {
|
||||||
|
|
||||||
results := make(chan error)
|
results := make(chan error)
|
||||||
pages := make(chan *PageOutput)
|
pages := make(chan *Page)
|
||||||
errs := make(chan error)
|
errs := make(chan error)
|
||||||
|
|
||||||
go errorCollator(results, errs)
|
go errorCollator(results, errs)
|
||||||
|
@ -44,9 +45,7 @@ func (s *Site) renderPages() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, page := range s.Pages {
|
for _, page := range s.Pages {
|
||||||
for _, outputType := range page.outputTypes {
|
pages <- page
|
||||||
pages <- newPageOutput(page, outputType)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close(pages)
|
close(pages)
|
||||||
|
@ -62,43 +61,45 @@ func (s *Site) renderPages() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func pageRenderer(s *Site, pages <-chan *PageOutput, results chan<- error, wg *sync.WaitGroup) {
|
func pageRenderer(s *Site, pages <-chan *Page, results chan<- error, wg *sync.WaitGroup) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
for p := range pages {
|
for page := range pages {
|
||||||
// TODO(bep) output check if some of the interface{} methods below checks for *Page
|
for i, outputType := range page.outputTypes {
|
||||||
var layouts []string
|
pageOutput := newPageOutput(page, i > 0, outputType)
|
||||||
|
|
||||||
if len(p.layoutsCalculated) > 0 {
|
var layouts []string
|
||||||
// TODO(bep) output
|
|
||||||
layouts = p.layoutsCalculated
|
|
||||||
} else {
|
|
||||||
layouts = s.layoutHandler.For(p.layoutIdentifier, "", p.outputType)
|
|
||||||
}
|
|
||||||
|
|
||||||
switch p.outputType {
|
if len(pageOutput.layoutsCalculated) > 0 {
|
||||||
|
// TODO(bep) output
|
||||||
case output.HTMLType:
|
layouts = pageOutput.layoutsCalculated
|
||||||
targetPath := p.TargetPath()
|
} else {
|
||||||
|
layouts = s.layoutHandler.For(pageOutput.layoutIdentifier, "", pageOutput.outputType)
|
||||||
s.Log.DEBUG.Printf("Render %s to %q with layouts %q", p.Kind, targetPath, layouts)
|
|
||||||
|
|
||||||
if err := s.renderAndWritePage("page "+p.FullFilePath(), targetPath, p, layouts...); err != nil {
|
|
||||||
results <- err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Taxonomy terms have no page set to paginate, so skip that for now.
|
switch pageOutput.outputType {
|
||||||
if p.IsNode() {
|
|
||||||
if err := s.renderPaginator(p); err != nil {
|
case output.HTMLType:
|
||||||
|
targetPath := pageOutput.TargetPath()
|
||||||
|
|
||||||
|
s.Log.DEBUG.Printf("Render %s to %q with layouts %q", pageOutput.Kind, targetPath, layouts)
|
||||||
|
|
||||||
|
if err := s.renderAndWritePage("page "+pageOutput.FullFilePath(), targetPath, pageOutput, layouts...); err != nil {
|
||||||
|
results <- err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Taxonomy terms have no page set to paginate, so skip that for now.
|
||||||
|
if pageOutput.IsNode() {
|
||||||
|
if err := s.renderPaginator(pageOutput); err != nil {
|
||||||
|
results <- err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case output.RSSType:
|
||||||
|
if err := s.renderRSS(pageOutput); err != nil {
|
||||||
results <- err
|
results <- err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case output.RSSType:
|
|
||||||
if err := s.renderRSS(p); err != nil {
|
|
||||||
results <- err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue