Changes

Jump to navigation Jump to search
8 bytes added ,  19:22, 15 February 2023
| '''Examples'''
|
* Request 100 URLs, use at most 8 parallel threads:<syntaxhighlight lang="xquery">xquery:fork-join( for $segment in 1 to 100 let $url := 'http://url.com/path/' || $segment return function() { http:send-request((), $url) }, map { 'parallel': 8 })* Parallel sleep function calls. The following function sleeps in parallel; it will be finished is expected to finish in 1 second if your the system has at least 2 cores:
<syntaxhighlight lang="xquery">
let $f := function() { prof:sleep(1000) }
return xquery:fork-join(($f, $f))
</syntaxhighlight>
* In the following query, up to four URLs will be requested in parallel:
<syntaxhighlight lang="xquery">
xquery:fork-join(
for $segment in 1 to 4
let $url := 'http://url.com/path/' || $segment
return function() { http:send-request((), $url) }
)
</syntaxhighlight>
|- valign="top"
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu