~ubuntu-branches/ubuntu/trusty/ocamlnet/trusty

« back to all changes in this revision

Viewing changes to doc/html-main/Netmcore_array.html

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-12-23 21:53:27 UTC
  • mfrom: (18.2.11 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131223215327-ezc6kxzldh4ki71o
Tags: 3.7.3-3build2
Rebuild for ocaml-4.01.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
<link title="Netmcore_hashtbl" rel="Chapter" href="Netmcore_hashtbl.html">
82
82
<link title="Netmcore_process" rel="Chapter" href="Netmcore_process.html">
83
83
<link title="Netmcore_tut" rel="Chapter" href="Netmcore_tut.html">
 
84
<link title="Netmcore_basics" rel="Chapter" href="Netmcore_basics.html">
84
85
<link title="Netplex_types" rel="Chapter" href="Netplex_types.html">
85
86
<link title="Netplex_mp" rel="Chapter" href="Netplex_mp.html">
86
87
<link title="Netplex_mt" rel="Chapter" href="Netplex_mt.html">
98
99
<link title="Netplex_sharedvar" rel="Chapter" href="Netplex_sharedvar.html">
99
100
<link title="Netplex_mutex" rel="Chapter" href="Netplex_mutex.html">
100
101
<link title="Netplex_encap" rel="Chapter" href="Netplex_encap.html">
 
102
<link title="Netplex_mbox" rel="Chapter" href="Netplex_mbox.html">
101
103
<link title="Netplex_intro" rel="Chapter" href="Netplex_intro.html">
102
104
<link title="Netplex_advanced" rel="Chapter" href="Netplex_advanced.html">
103
105
<link title="Netplex_admin" rel="Chapter" href="Netplex_admin.html">
122
124
<link title="Netaccel_link" rel="Chapter" href="Netaccel_link.html">
123
125
<link title="Nethtml" rel="Chapter" href="Nethtml.html">
124
126
<link title="Netstring_str" rel="Chapter" href="Netstring_str.html">
125
 
<link title="Netstring_pcre" rel="Chapter" href="Netstring_pcre.html">
126
127
<link title="Netmappings" rel="Chapter" href="Netmappings.html">
127
128
<link title="Netaux" rel="Chapter" href="Netaux.html">
128
129
<link title="Nethttp" rel="Chapter" href="Nethttp.html">
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">
157
160
<link title="Netsys_types" rel="Chapter" href="Netsys_types.html">
158
161
<link title="Netsys_mem" rel="Chapter" href="Netsys_mem.html">
159
162
<link title="Netsys_tmp" rel="Chapter" href="Netsys_tmp.html">
 
163
<link title="Netsys_sem" rel="Chapter" href="Netsys_sem.html">
 
164
<link title="Netsys_pmanage" rel="Chapter" href="Netsys_pmanage.html">
160
165
<link title="Netgzip" rel="Chapter" href="Netgzip.html">
161
166
<link title="Netpop" rel="Chapter" href="Netpop.html">
162
167
<link title="Rpc_auth_dh" rel="Chapter" href="Rpc_auth_dh.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>
196
202
</head>
197
203
<body>
198
 
<div class="navbar"><a href="Netmcore_ref.html">Previous</a>
199
 
&nbsp;<a href="index.html">Up</a>
200
 
&nbsp;<a href="Netmcore_sem.html">Next</a>
201
 
</div>
202
 
<center><h1>Module <a href="type_Netmcore_array.html">Netmcore_array</a></h1></center>
203
 
<br>
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
&nbsp;<a class="up" href="index.html" title="Index">Up</a>
 
206
&nbsp;<a class="post" href="Netmcore_sem.html" title="Netmcore_sem">Next</a>
 
207
</div>
 
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">
 
210
Shared arrays<br>
 
211
</div>
205
212
<hr width="100%">
206
213
<br>
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>
213
220
</ul>
214
221
<br>
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>
219
226
</div>
220
227
 
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>
224
231
</div>
225
232
 
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>
230
237
</div>
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
236
243
      as header.<br>
237
244
</div>
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>
244
251
</div>
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>.
248
255
<p>
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>
252
259
</div>
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>
256
263
</div>
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>
262
269
</div>
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>
268
275
</div>
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>
272
279
</div>
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>
275
282
</div>
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>
278
285
</div>
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>
281
288
</div>
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>
284
291
</div>
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>
287
294
</div>
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>
290
297
</div>
291
298
<br>
292
 
<span id="3_Mutatingheaderfields"><h3>Mutating header fields</h3></span>
 
299
<h3 id="3_Mutatingheaderfields">Mutating header fields</h3>
293
300
<p>
294
301
 
295
302
    Special care has to be taken when mutating header fields. The header
297
304
    has to use <a href="Netmcore_heap.html#VALmodify"><code class="code">Netmcore_heap.modify</code></a>. Example for a header of type:
298
305
<p>
299
306
 
300
 
    <pre><code class="code">    type header =
 
307
    <pre class="codepre"><code class="code">    type header =
301
308
      { mutable n : int;
302
309
        mutable name : string
303
310
      }
308
315
    is always an unboxed value. So,
309
316
<p>
310
317
 
311
 
    <pre><code class="code">    h.n &lt;- new_value
 
318
    <pre class="codepre"><code class="code">    h.n &lt;- new_value
312
319
    </code></pre>
313
320
<p>
314
321
 
316
323
    to <code class="code">name</code> we need to use <a href="Netmcore_heap.html#VALmodify"><code class="code">Netmcore_heap.modify</code></a>, as in
317
324
<p>
318
325
 
319
 
    <pre><code class="code">    Netmcore_heap.modify
 
326
    <pre class="codepre"><code class="code">    Netmcore_heap.modify
320
327
      (Netmcore_array.heap sa)
321
328
      (fun mutator -&gt;
322
329
        h.name &lt;- Netmcore_heap.add mutator new_value