summaryrefslogtreecommitdiff
path: root/jstests/parallel/shellfork.js
blob: ad05c0d4fbe307880da5a1e4066dd232a184f21a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
load('jstests/libs/parallelTester.js');

a = fork( function( a, b ) { return a / b; }, 10, 2 );
a.start();
b = fork( function( a, b, c ) { return a + b + c; }, 18, " is a ", "multiple of 3" );
makeFunny = function( text ) {
    return text + " ha ha!";
};
c = fork( makeFunny, "paisley" );
c.start();
b.start();
b.join();
assert.eq( 5, a.returnData() );
assert.eq( "18 is a multiple of 3", b.returnData() );
assert.eq( "paisley ha ha!", c.returnData() );

z = fork( function( a ) {
         load('jstests/libs/parallelTester.js');
         var y = fork( function( a ) {
                      return a + 1; }, 5 );
         y.start();
         return y.returnData() + a;
         }, 1 );
z.start();
assert.eq( 7, z.returnData() );


t = 1;
z = new ScopedThread( function() {
                     assert( typeof( t ) == "undefined", "t not undefined" );
                     t = 5;
                     return t;
                     } );
z.start();
assert.eq( 5, z.returnData() );
assert.eq( 1, t );