diff options
author | Russ Cox <rsc@golang.org> | 2012-02-19 18:04:38 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2012-02-19 18:04:38 -0500 |
commit | d76679a2f0fb99bf8500e3b766adea32f2761445 (patch) | |
tree | 01e963a20925682f59f1f573a8794260ea432fea /doc/go1.html | |
parent | 61b58edece31175e657d3d6af001866e81c5c9c3 (diff) | |
download | go-d76679a2f0fb99bf8500e3b766adea32f2761445.tar.gz |
doc/go1: update for runtime, unsafe API changes
Fixes issue 2890.
R=golang-dev, r, remyoudompheng
CC=golang-dev
http://codereview.appspot.com/5683044
Diffstat (limited to 'doc/go1.html')
-rw-r--r-- | doc/go1.html | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/doc/go1.html b/doc/go1.html index f4a4623db..04726069c 100644 --- a/doc/go1.html +++ b/doc/go1.html @@ -1635,15 +1635,41 @@ signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT) <h3 id="runtime">The runtime package</h3> <p> -The <code>runtime</code> package in Go 1 includes a new niladic function, +In Go 1, much of the API exported by package +<code>runtime</code> has been removed in favor of +functionality provided by other packages. +Code using the <code>runtime.Type</code> interface +or its specific concrete type implementations should +now use package <a href="/pkg/reflect/"><code>reflect</code></a>. +Code using <code>runtime.Semacquire</code> or <code>runtime.Semrelease</code> +should use channels or the abstractions in package <a href="/pkg/sync/"><code>sync</code></a>. +The <code>runtime.Alloc</code>, <code>runtime.Free</code>, +and <code>runtime.Lookup</code> functions, an unsafe API created for +debugging the memory allocator, have no replacement. +</p> + +<p> +Before, <code>runtime.MemStats</code> was a global variable holding +statistics about memory allocation, and calls to <code>runtime.UpdateMemStats</code> +ensured that it was up to date. +In Go 1, <code>runtime.MemStats</code> is a struct type, and code should use +<a href="/pkg/runtime/#ReadMemStats"><code>runtime.ReadMemStats</code></a> +to obtain the current statistics. +</p> + +<p> +The package adds a new function, <a href="/pkg/runtime/#NumCPU"><code>runtime.NumCPU</code></a>, that returns the number of CPUs available for parallel execution, as reported by the operating system kernel. Its value can inform the setting of <code>GOMAXPROCS</code>. +The <code>runtime.Cgocalls</code> and <code>runtime.Goroutines</code> functions +have been renamed to <code>runtime.NumCgoCall</code> and <code>runtime.NumGoroutine</code>. </p> <p> <em>Updating</em>: -No existing code is affected. +Running <code>go fix</code> will update code for the function renamings. +Other code will need to be updated by hand. </p> <h3 id="strconv">The strconv package</h3> @@ -1781,6 +1807,25 @@ The testing/script package has been deleted. It was a dreg. No code is likely to be affected. </p> +<h3 id="unsafe">The unsafe package</h3> + +<p> +In Go 1, the functions +<code>unsafe.Typeof</code>, <code>unsafe.Reflect</code>, +<code>unsafe.Unreflect</code>, <code>unsafe.New</code>, and +<code>unsafe.NewArray</code> have been removed; +they duplicated safer functionality provided by +package <a href="/pkg/reflect/"><code>reflect</code></a>. +</p> + +<p> +<em>Updating</em>: +Code using these functions must be rewritten to use +package <a href="/pkg/reflect/"><code>reflect</code></a>. +The changes to <a href="http://code.google.com/p/go/source/detail?r=2646dc956207">encoding/gob</a> and the <a href="http://code.google.com/p/goprotobuf/source/detail?r=5340ad310031">protocol buffer library</a> +may be helpful as examples. +</p> + <h3 id="url">The url package</h3> <p> |