update unit test cases of gmlock, concurrent safe reason

This commit is contained in:
John
2019-01-18 15:03:45 +08:00
parent 9e99e88d27
commit 616539ecb0
4 changed files with 22 additions and 5 deletions

View File

@ -16,7 +16,7 @@ import (
func TestLocker_Lock_Unlock(t *testing.T) {
gtest.Case(t, func() {
array := garray.New(0, 0, true)
array := garray.New(0, 0)
go func() {
gmlock.Lock("test")
array.Append(1)
@ -44,7 +44,7 @@ func TestLocker_Lock_Unlock(t *testing.T) {
func TestLocker_Lock_Expire(t *testing.T) {
gtest.Case(t, func() {
array := garray.New(0, 0, true)
array := garray.New(0, 0)
go func() {
gmlock.Lock("test", 50*time.Millisecond)
array.Append(1)
@ -64,7 +64,7 @@ func TestLocker_Lock_Expire(t *testing.T) {
func TestLocker_TryLock_Expire(t *testing.T) {
gtest.Case(t, func() {
array := garray.New(0, 0, true)
array := garray.New(0, 0)
go func() {
gmlock.Lock("test", 200*time.Millisecond)
array.Append(1)

View File

@ -16,7 +16,7 @@ import (
func TestLocker_RLock1(t *testing.T) {
gtest.Case(t, func() {
array := garray.New(0, 0, true)
array := garray.New(0, 0)
go func() {
gmlock.RLock("test")
array.Append(1)
@ -39,7 +39,7 @@ func TestLocker_RLock1(t *testing.T) {
func TestLocker_RLock2(t *testing.T) {
gtest.Case(t, func() {
array := garray.New(0, 0, true)
array := garray.New(0, 0)
go func() {
gmlock.Lock("test")
array.Append(1)

17
geg/os/gcron/gcron2.go Normal file
View File

@ -0,0 +1,17 @@
package main
import (
"gitee.com/johng/gf/g/os/gcron"
"gitee.com/johng/gf/g/os/glog"
"time"
)
func main() {
cron := gcron.New()
glog.Println("start")
cron.DelayAddOnce(1, "* * * * * *", func() {
glog.Println("run")
})
time.Sleep(10*time.Second)
}