forked from forgejo/forgejo
Integrate public as bindata optionally (#293)
* Dropped unused codekit config * Integrated dynamic and static bindata for public * Ignore public bindata * Add a general generate make task * Integrated flexible public assets into web command * Updated vendoring, added all missiong govendor deps * Made the linter happy with the bindata and dynamic code * Moved public bindata definition to modules directory * Ignoring the new bindata path now * Updated to the new public modules import path * Updated public bindata command and drop the new prefix
This commit is contained in:
parent
4680c349dd
commit
b6a95a8cb3
691 changed files with 305318 additions and 1272 deletions
56
vendor/github.com/ngaut/sync2/cond.go
generated
vendored
Normal file
56
vendor/github.com/ngaut/sync2/cond.go
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
// Copyright 2013, Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package sync2
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Cond is an alternate implementation of sync.Cond
|
||||
type Cond struct {
|
||||
L sync.Locker
|
||||
sema chan struct{}
|
||||
waiters AtomicInt64
|
||||
}
|
||||
|
||||
func NewCond(l sync.Locker) *Cond {
|
||||
return &Cond{L: l, sema: make(chan struct{})}
|
||||
}
|
||||
|
||||
func (c *Cond) Wait() {
|
||||
c.waiters.Add(1)
|
||||
c.L.Unlock()
|
||||
<-c.sema
|
||||
c.L.Lock()
|
||||
}
|
||||
|
||||
func (c *Cond) Signal() {
|
||||
for {
|
||||
w := c.waiters.Get()
|
||||
if w == 0 {
|
||||
return
|
||||
}
|
||||
if c.waiters.CompareAndSwap(w, w-1) {
|
||||
break
|
||||
}
|
||||
}
|
||||
c.sema <- struct{}{}
|
||||
}
|
||||
|
||||
func (c *Cond) Broadcast() {
|
||||
var w int64
|
||||
for {
|
||||
w = c.waiters.Get()
|
||||
if w == 0 {
|
||||
return
|
||||
}
|
||||
if c.waiters.CompareAndSwap(w, 0) {
|
||||
break
|
||||
}
|
||||
}
|
||||
for i := int64(0); i < w; i++ {
|
||||
c.sema <- struct{}{}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue