修改 命名

master
dengsgo 2018-12-30 15:14:14 +08:00
parent 755a7e8c07
commit afcceb7753
2 changed files with 10 additions and 10 deletions

View File

@ -24,7 +24,7 @@ var (
watcher *fsnotify.Watcher
tasker *Tasker
taskMan *TaskMan
)
type changeFile struct {
@ -61,7 +61,7 @@ func eventDispatcher(event fsnotify.Event) {
case fsnotify.Create:
case fsnotify.Write:
log.Println("event write : ", event.Name)
tasker.Put(&changeFile{
taskMan.Put(&changeFile{
Name: relativePath(projectFolder, event.Name),
Changed: time.Now().UnixNano(),
Ext: ext,
@ -130,7 +130,7 @@ func initWatcher() {
defer watcher.Close()
done := make(chan bool)
tasker = newTasker(2000)
taskMan = newTaskMan(2000)
go func() {
for {
select {
@ -177,7 +177,7 @@ func parseArgs() {
return
case "exec":
parseConfig()
newTasker(0).run(new(changeFile))
newTaskMan(0).run(new(changeFile))
return
case "version":
fallthrough

View File

@ -10,7 +10,7 @@ import (
"time"
)
type Tasker struct {
type TaskMan struct {
lastTaskId int64
delay int
cmd *exec.Cmd
@ -18,13 +18,13 @@ type Tasker struct {
runLock sync.Mutex
}
func newTasker(delay int) *Tasker {
return &Tasker{
func newTaskMan(delay int) *TaskMan {
return &TaskMan{
delay: delay,
}
}
func (t *Tasker) Put(cf *changeFile) {
func (t *TaskMan) Put(cf *changeFile) {
if t.delay < 1 {
t.preRun(cf)
return
@ -42,7 +42,7 @@ func (t *Tasker) Put(cf *changeFile) {
}()
}
func (t *Tasker) preRun(cf *changeFile) {
func (t *TaskMan) preRun(cf *changeFile) {
if t.cmd != nil {
err := t.cmd.Process.Kill()
if err != nil {
@ -53,7 +53,7 @@ func (t *Tasker) preRun(cf *changeFile) {
go t.run(cf)
}
func (t *Tasker) run(cf *changeFile) {
func (t *TaskMan) run(cf *changeFile) {
t.runLock.Lock()
defer t.runLock.Unlock()
for i := 0; i < len(cfg.Command.Exec); i++ {