mirror of
https://github.com/gogs/gogs.git
synced 2025-12-20 23:30:00 +01:00
commit0afcb843d7Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 17:13:29 2016 -0600 Removed Upload stats as the upload table is just a temporary table commit7ecd73ff55Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:42:41 2016 -0600 Fix for CodeMirror mode commitc29b9ab531Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:03:33 2016 -0600 Made tabbing in editor use spaces commit23af384c53Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:56:46 2016 -0600 Fix for data-url commitcfb8a97591Merge:7fc8a89991ce42Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:42:53 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit7fc8a89cb4Merge:fd3d86cc03d040Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:40:00 2016 -0600 Merge branch 'feature-create-and-edit-repo-file' of github.com:richmahn/gogs into feature-create-and-edit-repo-file commitfd3d86ca6bAuthor: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:39:44 2016 -0600 Code cleanup commitc03d0401c1Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 29 15:38:23 2016 -0600 Code cleanup commit98e1206ccfAuthor: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:36:01 2016 -0600 Code cleanup and fixes commitc2895dc742Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:24:04 2016 -0600 Fixes per Unknwon's requests commit6aa7e46b21Merge:889e9faad7ea88Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 17:13:43 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go modules/setting/setting.go commit889e9faf1bAuthor: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:09:18 2016 -0600 Fix in gogs.js commit47603edf22Merge:bb57912cf85e9eAuthor: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:07:36 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commitbb57912558Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:02:18 2016 -0600 Update for using CodeMirror mode addon commitd10d128c51Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 16:12:57 2016 -0600 Update for Edit commit34a3498202Merge:fa1b7521c7dcddAuthor: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 11:52:02 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go commitfa1b752be2Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 15 18:35:42 2016 -0600 Feature for editing, creating, uploading and deleting files
48 lines
1.0 KiB
Go
48 lines
1.0 KiB
Go
// Copyright 2015 The Gogs Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package models
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
// workingPool represents a pool of working status which makes sure
|
|
// that only one instance of same task is performing at a time.
|
|
// However, different type of tasks can performing at the same time.
|
|
type workingPool struct {
|
|
lock sync.Mutex
|
|
pool map[string]*sync.Mutex
|
|
count map[string]int
|
|
}
|
|
|
|
// CheckIn checks in a task and waits if others are running.
|
|
func (p *workingPool) CheckIn(name string) {
|
|
p.lock.Lock()
|
|
|
|
lock, has := p.pool[name]
|
|
if !has {
|
|
lock = &sync.Mutex{}
|
|
p.pool[name] = lock
|
|
}
|
|
p.count[name]++
|
|
|
|
p.lock.Unlock()
|
|
lock.Lock()
|
|
}
|
|
|
|
// CheckOut checks out a task to let other tasks run.
|
|
func (p *workingPool) CheckOut(name string) {
|
|
p.lock.Lock()
|
|
defer p.lock.Unlock()
|
|
|
|
p.pool[name].Unlock()
|
|
if p.count[name] == 1 {
|
|
delete(p.pool, name)
|
|
delete(p.count, name)
|
|
} else {
|
|
p.count[name]--
|
|
}
|
|
}
|