-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path16-allapply.cfc
41 lines (32 loc) · 1.14 KB
/
16-allapply.cfc
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
37
38
39
40
41
component extends="../BaseTask" {
function init() {
super.init();
loadModule( shell.pwd() & "modules/mockdatacfc" );
variables.mock = getInstance( "MockData@mockdatacfc" );
}
function getObject(){
return {
"getMemento" = () => {
return mock.mock(
"$returnType" : "struct",
"name" : "name",
"age" : "age",
"id" : "uuid"
);
}
};
}
function run(){
// Build objects async
var aObjects = asyncManager.allApply(
[].append( asyncManager.arrayRange( "1..200" ), true ),
(item) => getObject()
);
// Process them
asyncManager.allApply( aObjects, ( item ) => item.getMemento() )
// .thenRun( ( result ) => print.line( "does this work?" ).toConsole() )
// .allApply( data, ( item ) => item.getMemento(), asyncManager.$executors.newFixedThreadPool( 50 ) )
.each( (item) => print.blueLine( item.toString() ).toConsole() )
// 1. Now let's use a custom executor
}
}