lab.nexedi.com/kirr/go123@v0.0.0-20240207185015-8299741fa871/tracing/internal/xruntime/runtime.go (about) 1 // Copyright (C) 2016-2023 Nexedi SA and Contributors. 2 // Kirill Smelkov <kirr@nexedi.com> 3 // 4 // This program is free software: you can Use, Study, Modify and Redistribute 5 // it under the terms of the GNU General Public License version 3, or (at your 6 // option) any later version, as published by the Free Software Foundation. 7 // 8 // You can also Link and Combine this program with other software covered by 9 // the terms of any of the Free Software licenses or any of the Open Source 10 // Initiative approved licenses and Convey the resulting work. Corresponding 11 // source of such a combination shall include the source code for all other 12 // software used. 13 // 14 // This program is distributed WITHOUT ANY WARRANTY; without even the implied 15 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 // 17 // See COPYING file for full licensing terms. 18 // See https://www.nexedi.com/licensing for rationale and options. 19 20 package xruntime 21 // stop-the-world that should probably be in public xruntime, but I'm (yet) 22 // hesitating to expose the API to public. 23 24 // StopTheWorld returns with the world stopped. 25 // 26 // Current goroutine remains the only one who is running, with others 27 // goroutines stopped at safe GC points. 28 // It requires careful programming as many things that normally work lead to 29 // fatal errors when the world is stopped - for example using timers would be 30 // invalid, but adjusting plain values in memory is ok. 31 func StopTheWorld(reason string) { 32 stopTheWorld(reason) 33 } 34 35 // StartTheWorld restarts the world after it was stopped by StopTheWorld. 36 func StartTheWorld() { 37 startTheWorld() 38 }