Imported Upstream version 4.6.0.125

Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-08-03 10:59:49 +00:00
parent a569aebcfd
commit e79aa3c0ed
17047 changed files with 3137615 additions and 392334 deletions

View File

@@ -1,60 +1,197 @@
<?xml version="1.0" encoding="utf-8"?><span>
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>mono-api-gchandle.html</title>
<style type="text/css">
<title>mono-api-gchandle.html</title>
<style type="text/css">
.mapi-docs {
line-height: 1.5;
padding-left: 2em;
padding-right: 2em;
}
.mapi-docs p {
max-width: 60em;
}
.mapi-docs .mapi-body {
max-width: 60em;
}
.mapi-docs code {
border: 1px solid rgba(214,214,214,1);
background-color: rgba(249,249,249,1);
padding: 0.1em 0.5em;
}
.mapi-description code {
font-family: "Consolas", "Courier", monospace;
border: 1px solid rgba(214,214,214,1);
background-color: rgba(249,249,249,1);
padding: 0.1em 0.2em;
}
h3 {
font-size: 18px;
padding-bottom: 4pt;
border-bottom: 2px solid #dddddd;
}
.api {
border: 1px solid;
padding: 10pt;
margin: 10pt;
}
.mapi-header {
padding: 0 0 5pt 5pt;
margin: 10pt;
white-space: pre;
font-family: monospace;
border: 1px solid rgba(233,233,233,1);
background-color: rgba(249,249,249,1);
}
.api-entry {
border-bottom: none;
font-size: 18px;
}
.mapi-code {
padding: 5pt 5pt;
margin: 10pt;
white-space: pre;
font-family: monospace;
border: 1px solid rgba(233,233,233,1);
background-color: rgba(249,249,249,1);
}
.prototype {
border: 1px solid;
background-color: #f2f2f2;
padding: 5pt;
margin-top: 5pt;
margin-bottom: 5pt;
}
.mapi-code:first-line {
line-height: 0px;
}
.header {
border: 1px solid;
padding: 0 0 5pt 5pt;
margin: 10pt;
white-space: pre;
font-family: monospace;
}
.mapi-entry code {
border: none;
background-color: transparent;
}
.code {
border: 1px solid;
padding: 0 0 5pt 5pt;
margin: 10pt;
white-space: pre;
font-family: monospace;
}
.mapi-parameters {
border-collapse: collapse;
border-spacing: 0;
empty-cells: hide;
border: 0;
margin: 5px 0 26px;
}
.mapi-parameters td {
border: 1px solid rgba(214,214,214,1);
border-left-style: none;
padding: 5px 25px 5px 10px;
}
.mapi-parameters tr>td:last-child {
border-right: 0;
}
.mapi-parameters td:first-of-type {
text-align: right;
padding: 7px;
vertical-align: top;
word-break: normal;
width: 40px;
}
.mapi-parameters tr:last-child>td {
border-bottom: 0;
}
.mapi-parameters tr:first-child>td {
border-top: 0;
}
.mapi-parameters tr td:first-of-type {
text-align: right;
padding: 7px;
vertical-align: top;
word-break: normal;
width: 40px;
}
.mapi {
left: -25px;
margin: 0;
padding: 13px 25px 0;
position: relative;
width: 100%;
}
.mapi-description {
background: rgba(249,249,249,1);
border-bottom: 1px solid rgba(233,233,233,1);
left: -25px;
margin: 0;
padding: 13px 25px 0;
position: relative;
width: 100%;
}
.mapi-entry {
background: transparent;
}
.mapi-docs {
}
.mapi-prototype {
border-left: 5px solid rgba(205,233,244,1);
padding: .5em;
margin-top: 5pt;
margin-bottom: 5pt;
font-family: "Consolas", "Courier", monospace;
display: block;
overflow: auto;
background-color: #f9f9f9;
}
.mapi-declaration {
margin-top: 21px;
}
.mapi-section {
font-size: smaller;
font-weight: bold;
margin-top: 21px;
line-height: 1.5;
}
.mapi-strike {
text-decoration: line-through;
}
.mapi-deprecated {
color: red;
}
.mapi-ptr-container {
background: white;
border-bottom: 1px solid rgba(233,233,233,1);
left: -25px;
padding-left: 25px;
padding-right: 25px;
padding-bottom: 13px;
position: relative;
width: 100%;
}
.mapi-ptr {
background: rgba(249,249,249,1);
border-left: 1px solid rgba(233,233,233,1);
border-top: 1px solid rgba(233,233,233,1);
height: 12px;
left: 37px;
top: -7px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
position: absolute;
width: 12px;
}
.mapi-height-container {
left: -25px;
padding: 0 25px;
position: relative;
width: 100%;
}
</style>
</head>
<body>
<div class="mapi-docs">
<h1>GC Handles</h1>
<h3>Synopsys</h3>
<div class="header">
<div class="mapi-header">
guint32 <a href="#api:mono_gchandle_new">mono_gchandle_new</a> (GCObject *obj,
gboolean pinned);
guint32 <a href="#api:mono_gchandle_new_weakref">mono_gchandle_new_weakref</a> (GCObject *obj,
@@ -87,7 +224,8 @@ void <a href="#api:mono_gchandle_free">mono_gchandle_free</a> (guint
<tt>mono_gchandle_get_target</tt>.
<p />For example, consider the following C code:
<div class="code">
<div class="mapi-code">
static MonoObject* o = NULL;
</div>
@@ -97,22 +235,22 @@ static MonoObject* o = NULL;
it from being collected, you need to acquire a GC handle for
it.
<div class="code">
guint32 handle = mono_gchandle_new (my_object, TRUE);
<div class="mapi-code">
guint32 handle = mono_gchandle_new (my_object, TRUE);
</div>
<p />TRUE means the object will be pinned, so it won't move in
memory when we'll use a moving GC. You can access the
MonoObject* referenced by a handle with:
<div class="code">
MonoObject* obj = mono_gchandle_get_target (handle);
<div class="mapi-code">
MonoObject* obj = mono_gchandle_get_target (handle);
</div>
<p />When you don't need the handle anymore you need to call:
<div class="code">
mono_gchandle_free (handle);
<div class="mapi-code">
mono_gchandle_free (handle);
</div>
<p />Note that if you assign a new object to the C var, you need
@@ -121,108 +259,125 @@ static MonoObject* o = NULL;
<p />So code that looked like this:
<div class="code">
static MonoObject* o = NULL;
...
o = mono_object_new (...);
/* use o */
...
/* when done to allow the GC to collect o */
o = NULL;
<div class="mapi-code">
static MonoObject* obj = NULL;
...
obj = mono_object_new (...);
// use obj
...
// when done to allow the GC to collect obj
obj = NULL;
</div>
<p />should now be changed to:
<div class="code">
static guint32 o_handle;
...
MonoObject *o = mono_object_new (...);
o_handle = mono_gchandle_new (o, TRUE);
/* use o or mono_gchandle_get_target (o_handle) */
...
/* when done to allow the GC to collect o */
mono_gchandle_free (o_handle);
<div class="mapi-code">
static guint32 o_handle;
...
MonoObject *obj = mono_object_new (...);
o_handle = mono_gchandle_new (obj, TRUE);
// use o or mono_gchandle_get_target (o_handle)
...
// when done to allow the GC to collect obj
mono_gchandle_free (o_handle);
</div>
<a name="api:mono_gchandle_new"></a>
<div class="api">
<div class="api-entry">mono_gchandle_new</div>
<a name="api:mono_gchandle_new"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_gchandle_new</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="prototype">guint32
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">guint32
mono_gchandle_new (GCObject *obj, gboolean pinned)
</div>
<p />
<b>Parameters</b>
<blockquote><dt><i>obj:</i></dt><dd> managed object to get a handle for</dd><dt><i>pinned:</i></dt><dd> whether the object should be pinned</dd></blockquote>
<b>Returns</b>
<blockquote> a handle that can be used to access the object from
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>obj</i><td> managed object to get a handle for</td></td></tr><tr><td><i>pinned</i><td> whether the object should be pinned</td></td></tr></tbody></table> <div class="mapi-section">Return value</div>
<div> a handle that can be used to access the object from
unmanaged code.</blockquote>
<b>Remarks</b>
<p />
unmanaged code.</div>
<div class="mapi-section">Description</div>
<div> <p />
This returns a handle that wraps the object, this is used to keep a
reference to a managed object from the unmanaged world and preventing the
object from being disposed.
<p />
<p />
If <i>pinned</i> is false the address of the object can not be obtained, if it is
true the address of the object can be obtained. This will also pin the
object so it will not be possible by a moving garbage collector to move the
object.
<p />
<p /></div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
</div> <a name="api:mono_gchandle_new_weakref"></a>
<div class="api">
<div class="api-entry">mono_gchandle_new_weakref</div>
<a name="api:mono_gchandle_new_weakref"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_gchandle_new_weakref</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="prototype">guint32
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">guint32
mono_gchandle_new_weakref (GCObject *obj, gboolean track_resurrection)
</div>
<p />
<b>Parameters</b>
<blockquote><dt><i>obj:</i></dt><dd> managed object to get a handle for</dd><dt><i>pinned:</i></dt><dd> whether the object should be pinned</dd></blockquote>
<b>Returns</b>
<blockquote> a handle that can be used to access the object from
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>obj</i><td> managed object to get a handle for</td></td></tr><tr><td><i>track_resurrection</i><td> Determines how long to track the object, if this is set to <code>TRUE</code>, the object is tracked after finalization, if <code>FALSE</code>, the object is only tracked up until the point of finalization.</td></td></tr></tbody></table> <div class="mapi-section">Return value</div>
<div> a handle that can be used to access the object from
unmanaged code.</blockquote>
<b>Remarks</b>
<p />
unmanaged code.</div>
<div class="mapi-section">Description</div>
<div> <p />
This returns a weak handle that wraps the object, this is used to
keep a reference to a managed object from the unmanaged world.
Unlike the mono_gchandle_new the object can be reclaimed by the
garbage collector. In this case the value of the GCHandle will be
set to zero.
<p />
If <i>pinned</i> is false the address of the object can not be obtained, if it is
true the address of the object can be obtained. This will also pin the
object so it will not be possible by a moving garbage collector to move the
object.
<p />
<p />
If <i>track_resurrection</i> is <code>TRUE</code> the object will be tracked through
finalization and if the object is resurrected during the execution
of the finalizer, then the returned weakref will continue to hold
a reference to the object. If <i>track_resurrection</i> is <code>FALSE</code>, then
the weak reference's target will become <code>NULL</code> as soon as the object
is passed on to the finalizer.
<p /></div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
</div> <a name="api:mono_gchandle_get_target"></a>
<div class="api">
<div class="api-entry">mono_gchandle_get_target</div>
<a name="api:mono_gchandle_get_target"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_gchandle_get_target</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="prototype">GCObject*
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">GCObject*
mono_gchandle_get_target (guint32 gchandle)
</div>
<p />
<b>Parameters</b>
<blockquote><dt><i>gchandle:</i></dt><dd> a GCHandle's handle.</dd></blockquote>
<b>Remarks</b>
<p />
The handle was previously created by calling mono_gchandle_new or
mono_gchandle_new_weakref.
Returns a pointer to the MonoObject represented by the handle or
NULL for a collected object if using a weakref handle.
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>gchandle</i><td> a GCHandle's handle.</td></td></tr></tbody></table> <div class="mapi-section">Description</div>
<div> <p />
The handle was previously created by calling <code>mono_gchandle_new</code> or
<code>mono_gchandle_new_weakref</code>.
<p />
Returns a pointer to the <code>MonoObject*</code> represented by the handle or
<code>NULL</code> for a collected object if using a weakref handle.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div>
</div></body>
</html>
</span>