136
137
<link title="Xdr_mstring" rel="Chapter" href="Xdr_mstring.html">
137
138
<link title="Xdr" rel="Chapter" href="Xdr.html">
138
139
<link title="Netcompression" rel="Chapter" href="Netcompression.html">
140
<link title="Netunichar" rel="Chapter" href="Netunichar.html">
139
141
<link title="Netchannels_tut" rel="Chapter" href="Netchannels_tut.html">
140
142
<link title="Netmime_tut" rel="Chapter" href="Netmime_tut.html">
141
143
<link title="Netsendmail_tut" rel="Chapter" href="Netsendmail_tut.html">
142
144
<link title="Netulex_tut" rel="Chapter" href="Netulex_tut.html">
143
145
<link title="Neturl_tut" rel="Chapter" href="Neturl_tut.html">
146
<link title="Netstring_pcre" rel="Chapter" href="Netstring_pcre.html">
144
147
<link title="Netsys" rel="Chapter" href="Netsys.html">
145
148
<link title="Netsys_posix" rel="Chapter" href="Netsys_posix.html">
146
149
<link title="Netsys_pollset" rel="Chapter" href="Netsys_pollset.html">
191
196
<link title="Intro" rel="Chapter" href="Intro.html">
192
197
<link title="Platform" rel="Chapter" href="Platform.html">
193
198
<link title="Foreword" rel="Chapter" href="Foreword.html">
194
<link title="Ipv6" rel="Chapter" href="Ipv6.html"><link title="Mutating header fields" rel="Section" href="#3_Mutatingheaderfields">
199
<link title="Ipv6" rel="Chapter" href="Ipv6.html">
200
<link title="Regexp" rel="Chapter" href="Regexp.html"><link title="Mutating header fields" rel="Section" href="#3_Mutatingheaderfields">
195
201
<title>Ocamlnet 3 Reference Manual : Netmcore_array</title>
198
<div class="navbar"><a href="Netmcore_ref.html">Previous</a>
199
<a href="index.html">Up</a>
200
<a href="Netmcore_sem.html">Next</a>
202
<center><h1>Module <a href="type_Netmcore_array.html">Netmcore_array</a></h1></center>
204
<pre><span class="keyword">module</span> Netmcore_array: <code class="code">sig</code> <a href="Netmcore_array.html">..</a> <code class="code">end</code></pre>Shared arrays<br>
204
<div class="navbar"><a class="pre" href="Netmcore_ref.html" title="Netmcore_ref">Previous</a>
205
<a class="up" href="index.html" title="Index">Up</a>
206
<a class="post" href="Netmcore_sem.html" title="Netmcore_sem">Next</a>
208
<h1>Module <a href="type_Netmcore_array.html">Netmcore_array</a></h1>
209
<pre><span class="keyword">module</span> Netmcore_array: <code class="code">sig</code> <a href="Netmcore_array.html">..</a> <code class="code">end</code></pre><div class="info">
205
212
<hr width="100%">
207
214
This type of array is to some degree comparable with <code class="code">Array</code>, but
212
219
<li>The arrays can be grown in size</li>
215
<pre><span id="TYPEsarray"><span class="keyword">type</span> <code class="type">('a, 'b)</code> sarray</span> </pre>
222
<pre><span id="TYPEsarray"><span class="keyword">type</span> <code class="type">('e, 'h)</code> sarray</span> </pre>
216
223
<div class="info">
217
224
Arrays where the elements have type <code class="code">'e</code> and the header has
218
225
type <code class="code">'h</code><br>
221
<pre><span id="TYPEsarray_descr"><span class="keyword">type</span> <code class="type">('a, 'b)</code> sarray_descr</span> </pre>
228
<pre><span id="TYPEsarray_descr"><span class="keyword">type</span> <code class="type">('e, 'h)</code> sarray_descr</span> </pre>
222
229
<div class="info">
223
230
The marshallable descriptor of a shared array<br>
226
<pre><span id="VALcreate"><span class="keyword">val</span> create</span> : <code class="type"><a href="Netmcore.html#TYPEres_id">Netmcore.res_id</a> -> 'a array -> 'b -> ('a, 'b) <a href="Netmcore_array.html#TYPEsarray">sarray</a></code></pre><div class="info">
233
<pre><span id="VALcreate"><span class="keyword">val</span> create</span> : <code class="type"><a href="Netmcore.html#TYPEres_id">Netmcore.res_id</a> -> 'e array -> 'h -> ('e, 'h) <a href="Netmcore_array.html#TYPEsarray">sarray</a></code></pre><div class="info">
227
234
<code class="code">create pool_id a h</code>:
228
235
Creates a shared array by deeply copying a normal array <code class="code">a</code>
229
236
and using the copy of <code class="code">h</code> as header<br>
231
<pre><span id="VALmake"><span class="keyword">val</span> make</span> : <code class="type"><a href="Netmcore.html#TYPEres_id">Netmcore.res_id</a> -> int -> 'a -> 'b -> ('a, 'b) <a href="Netmcore_array.html#TYPEsarray">sarray</a></code></pre><div class="info">
238
<pre><span id="VALmake"><span class="keyword">val</span> make</span> : <code class="type"><a href="Netmcore.html#TYPEres_id">Netmcore.res_id</a> -> int -> 'e -> 'h -> ('e, 'h) <a href="Netmcore_array.html#TYPEsarray">sarray</a></code></pre><div class="info">
232
239
<code class="code">make pool_id n x h</code>:
233
240
Creates a shared array of the passed number of elements,
234
241
copies the element <code class="code">x</code>, and initializes each element of the new array
235
242
with the single copy of <code class="code">x</code>. The value <code class="code">h</code> is copied and used
238
<pre><span id="VALinit"><span class="keyword">val</span> init</span> : <code class="type"><a href="Netmcore.html#TYPEres_id">Netmcore.res_id</a> -> int -> (int -> 'a) -> 'b -> ('a, 'b) <a href="Netmcore_array.html#TYPEsarray">sarray</a></code></pre><div class="info">
245
<pre><span id="VALinit"><span class="keyword">val</span> init</span> : <code class="type"><a href="Netmcore.html#TYPEres_id">Netmcore.res_id</a> -> int -> (int -> 'e) -> 'h -> ('e, 'h) <a href="Netmcore_array.html#TYPEsarray">sarray</a></code></pre><div class="info">
239
246
<code class="code">init pool_id n f h</code>:
240
247
Creates a shared array of the passed number of elements,
241
248
and for getting the element at position <code class="code">k</code> the function
242
249
<code class="code">f k</code> is run, and the copy of the result is written to the
243
250
position. The header is set to the copy of <code class="code">h</code>.<br>
245
<pre><span id="VALgrow"><span class="keyword">val</span> grow</span> : <code class="type">('a, 'b) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> int -> 'a -> unit</code></pre><div class="info">
252
<pre><span id="VALgrow"><span class="keyword">val</span> grow</span> : <code class="type">('e, 'a) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> int -> 'e -> unit</code></pre><div class="info">
246
253
<code class="code">grow sa n x</code>: Grows the array to <code class="code">n</code> elements. The new elements
247
254
are initialized to a (single) copy of <code class="code">x</code>.
250
257
If <code class="code">n</code> is smaller than the current length, the function will do
251
258
nothing, and keep the length.<br>
253
<pre><span id="VALset"><span class="keyword">val</span> set</span> : <code class="type">('a, 'b) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> int -> 'a -> unit</code></pre><div class="info">
260
<pre><span id="VALset"><span class="keyword">val</span> set</span> : <code class="type">('e, 'a) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> int -> 'e -> unit</code></pre><div class="info">
254
261
<code class="code">set sa k x</code>: Sets the <code class="code">k-th</code> element of the array <code class="code">sa</code> to a
255
262
deep copy of <code class="code">x</code>.<br>
257
<pre><span id="VALget_ro"><span class="keyword">val</span> get_ro</span> : <code class="type">('a, 'b) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> int -> 'a</code></pre><div class="info">
264
<pre><span id="VALget_ro"><span class="keyword">val</span> get_ro</span> : <code class="type">('e, 'a) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> int -> 'e</code></pre><div class="info">
258
265
<code class="code">get_ro sa k</code>: Gets the <code class="code">k</code>-th element of the shared array <code class="code">sa</code>.
259
266
Note that there is no guarantee that this value still exists if
260
267
it is returned, and a parallely running <code class="code">set</code> changes this element.
261
268
If such values are accessed the program may crash!<br>
263
<pre><span id="VALget_p"><span class="keyword">val</span> get_p</span> : <code class="type">('a, 'b) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> int -> ('a -> 'c) -> 'c</code></pre><div class="info">
270
<pre><span id="VALget_p"><span class="keyword">val</span> get_p</span> : <code class="type">('e, 'b) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> int -> ('e -> 'a) -> 'a</code></pre><div class="info">
264
271
<code class="code">get_p sa k f</code>: Gets the <code class="code">k</code>-th element of the shared array <code class="code">sa</code>
265
272
and call <code class="code">f</code> with this element, and returns the result of <code class="code">f</code>.
266
273
During the execution of <code class="code">f</code> the requested element cannot be
267
274
garbage collected.<br>
269
<pre><span id="VALget_c"><span class="keyword">val</span> get_c</span> : <code class="type">('a, 'b) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> int -> 'a</code></pre><div class="info">
276
<pre><span id="VALget_c"><span class="keyword">val</span> get_c</span> : <code class="type">('e, 'a) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> int -> 'e</code></pre><div class="info">
270
277
<code class="code">get_c sa k</code>: Gets a copy of the <code class="code">k</code>-th element of the shared array
271
278
<code class="code">sæ</code><br>
273
280
<pre><span id="VALlength"><span class="keyword">val</span> length</span> : <code class="type">('a, 'b) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> int</code></pre><div class="info">
274
281
Returns the length<br>
276
<pre><span id="VALheader"><span class="keyword">val</span> header</span> : <code class="type">('a, 'b) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> 'b</code></pre><div class="info">
283
<pre><span id="VALheader"><span class="keyword">val</span> header</span> : <code class="type">('a, 'h) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> 'h</code></pre><div class="info">
277
284
Returns the header<br>
279
<pre><span id="VALderef"><span class="keyword">val</span> deref</span> : <code class="type">('a, 'b) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> 'a array</code></pre><div class="info">
286
<pre><span id="VALderef"><span class="keyword">val</span> deref</span> : <code class="type">('e, 'a) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> 'e array</code></pre><div class="info">
280
287
Returns the raw array in shared memory for unprotected access<br>
282
289
<pre><span id="VALheap"><span class="keyword">val</span> heap</span> : <code class="type">('a, 'b) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> Obj.t <a href="Netmcore_heap.html#TYPEheap">Netmcore_heap.heap</a></code></pre><div class="info">
283
290
Return the backing heap structure<br>
285
<pre><span id="VALdescr_of_sarray"><span class="keyword">val</span> descr_of_sarray</span> : <code class="type">('a, 'b) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> ('a, 'b) <a href="Netmcore_array.html#TYPEsarray_descr">sarray_descr</a></code></pre><div class="info">
292
<pre><span id="VALdescr_of_sarray"><span class="keyword">val</span> descr_of_sarray</span> : <code class="type">('e, 'h) <a href="Netmcore_array.html#TYPEsarray">sarray</a> -> ('e, 'h) <a href="Netmcore_array.html#TYPEsarray_descr">sarray_descr</a></code></pre><div class="info">
286
293
Returns the descriptor<br>
288
<pre><span id="VALsarray_of_descr"><span class="keyword">val</span> sarray_of_descr</span> : <code class="type"><a href="Netmcore.html#TYPEres_id">Netmcore.res_id</a> -><br> ('a, 'b) <a href="Netmcore_array.html#TYPEsarray_descr">sarray_descr</a> -> ('a, 'b) <a href="Netmcore_array.html#TYPEsarray">sarray</a></code></pre><div class="info">
295
<pre><span id="VALsarray_of_descr"><span class="keyword">val</span> sarray_of_descr</span> : <code class="type"><a href="Netmcore.html#TYPEres_id">Netmcore.res_id</a> -><br> ('e, 'h) <a href="Netmcore_array.html#TYPEsarray_descr">sarray_descr</a> -> ('e, 'h) <a href="Netmcore_array.html#TYPEsarray">sarray</a></code></pre><div class="info">
289
296
Look up the buffer for this descriptor<br>
292
<span id="3_Mutatingheaderfields"><h3>Mutating header fields</h3></span>
299
<h3 id="3_Mutatingheaderfields">Mutating header fields</h3>
295
302
Special care has to be taken when mutating header fields. The header