-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I58178d6d6c832f7dcf9a41b9821a6acff9f0a149
- Loading branch information
Showing
14 changed files
with
248 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//go:build go1.22 && !go1.23 | ||
// +build go1.22,!go1.23 | ||
|
||
/* | ||
* Copyright 2022 ByteDance Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package stw | ||
|
||
import ( | ||
_ "unsafe" | ||
) | ||
|
||
func newSTWCtx() ctx { | ||
return &stwCtx{} | ||
} | ||
|
||
type stwCtx struct { | ||
w worldStop | ||
} | ||
|
||
const stwForTestResetDebugLog = 16 | ||
|
||
func (ctx *stwCtx) StopTheWorld() { | ||
ctx.w = stopTheWorld(stwForTestResetDebugLog) | ||
} | ||
func (ctx *stwCtx) StartTheWorld() { | ||
startTheWorld(ctx.w) | ||
} | ||
|
||
// stwReason is an enumeration of reasons the world is stopping. | ||
type stwReason uint8 | ||
|
||
// worldStop provides context from the stop-the-world required by the | ||
// start-the-world. | ||
type worldStop struct { | ||
reason stwReason | ||
start int64 | ||
} | ||
|
||
//go:linkname stopTheWorld runtime.stopTheWorld | ||
func stopTheWorld(reason stwReason) worldStop | ||
|
||
//go:linkname startTheWorld runtime.startTheWorld | ||
func startTheWorld(w worldStop) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//go:build go1.23 && mockey_stw | ||
// +build go1.23,mockey_stw | ||
|
||
/* | ||
* Copyright 2022 ByteDance Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package stw | ||
|
||
import ( | ||
_ "unsafe" | ||
) | ||
|
||
func newSTWCtx() ctx { | ||
return &stwCtx{} | ||
} | ||
|
||
type stwCtx struct { | ||
w worldStop | ||
} | ||
|
||
const stwForTestResetDebugLog = 16 | ||
|
||
func (ctx *stwCtx) StopTheWorld() { | ||
ctx.w = stopTheWorld(stwForTestResetDebugLog) | ||
} | ||
func (ctx *stwCtx) StartTheWorld() { | ||
startTheWorld(ctx.w) | ||
} | ||
|
||
// stwReason is an enumeration of reasons the world is stopping. | ||
type stwReason uint8 | ||
|
||
// worldStop provides context from the stop-the-world required by the | ||
// start-the-world. | ||
type worldStop struct { | ||
reason stwReason | ||
startedStopping int64 | ||
finishedStopping int64 | ||
stoppingCPUTime int64 | ||
} | ||
|
||
//go:linkname stopTheWorld runtime.stopTheWorld | ||
func stopTheWorld(reason stwReason) worldStop | ||
|
||
//go:linkname startTheWorld runtime.startTheWorld | ||
func startTheWorld(w worldStop) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2022 ByteDance Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package stw | ||
|
||
type ctx interface { | ||
StopTheWorld() | ||
StartTheWorld() | ||
} | ||
|
||
func NewSTWCtx() ctx { | ||
return newSTWCtx() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.