mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 03:50:25 +00:00
Fixed deadlock.
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
**1.2.2**
|
||||||
|
|
||||||
|
* bugfix: deadlock on compiling multile files at once
|
||||||
|
|
||||||
**1.2.1**
|
**1.2.1**
|
||||||
|
|
||||||
* bugfix: new line after while for pretty printing
|
* bugfix: new line after while for pretty printing
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
version = "1.2.1"
|
version = "1.2.2"
|
||||||
extension = ".asl"
|
extension = ".asl"
|
||||||
sqfextension = ".sqf"
|
sqfextension = ".sqf"
|
||||||
typeinfo = "types"
|
typeinfo = "types"
|
||||||
@@ -104,17 +104,15 @@ func readAslFiles(path string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Recovers and prints thrown error.
|
// Recovers and prints thrown error.
|
||||||
func recoverCompileError(file string, waiter chan bool) {
|
func recoverCompileError(file string) {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
fmt.Println("Compile error in file "+file+":", r)
|
fmt.Println("Compile error in file "+file+":", r)
|
||||||
}
|
}
|
||||||
|
|
||||||
waiter <- true // the show must go on
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compiles a single ASL file.
|
// Compiles a single ASL file.
|
||||||
func compileFile(path string, file ASLFile, waiter chan bool) {
|
func compileFile(path string, file ASLFile) {
|
||||||
defer recoverCompileError(file.in, waiter)
|
defer recoverCompileError(file.in)
|
||||||
|
|
||||||
// read file
|
// read file
|
||||||
out := filepath.FromSlash(path + PathSeparator + file.out + PathSeparator + file.newname + sqfextension)
|
out := filepath.FromSlash(path + PathSeparator + file.out + PathSeparator + file.newname + sqfextension)
|
||||||
@@ -138,22 +136,12 @@ func compileFile(path string, file ASLFile, waiter chan bool) {
|
|||||||
fmt.Println("Error writing file: " + file.out)
|
fmt.Println("Error writing file: " + file.out)
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
waiter <- true // done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compiles ASL files concurrently.
|
// Compiles ASL files.
|
||||||
func compile(path string) {
|
func compile(path string) {
|
||||||
waiter := make(chan bool, len(aslFiles))
|
|
||||||
|
|
||||||
// fire compile
|
|
||||||
for i := 0; i < len(aslFiles); i++ {
|
for i := 0; i < len(aslFiles); i++ {
|
||||||
go compileFile(path, aslFiles[i], waiter)
|
compileFile(path, aslFiles[i])
|
||||||
}
|
|
||||||
|
|
||||||
// wait until all files are compiled
|
|
||||||
for i := 0; i < len(aslFiles); i++ {
|
|
||||||
<-waiter
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user