mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
update unit test cases of gmlock, concurrent safe reason
This commit is contained in:
@ -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)
|
||||
|
||||
@ -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
17
geg/os/gcron/gcron2.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user