-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01-intro-to-futures.cfc
78 lines (69 loc) · 1.82 KB
/
01-intro-to-futures.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* This exercise goes over:
* + creating new Futures
* + running Futures
* + waiting for Futures to complete
* + Assigning timeouts and default values to Futures
*
* You can run this exercise from the root in CommandBox by running:
* `task run exercises/01-intro-to-futures.cfc`
*
* You can use the `print` helper provided by CommandBox to log messages.
* (Use `print.line( "message" ).toConsole()` if you're not familiar with it.)
* Make sure to end with `.toConsole()` so your message is flushed
* to the console the moment it is printed.
*/
component extends="../BaseTask" {
/**
* Create a future that prints out a greeting immediately.
*/
function partOne(){
return;
}
/**
* Create a future that prints out a greeting after 2 seconds.
*/
function partTwo(){
return;
}
/**
* Create a future that _returns_ a message to print out after 5 seconds.
* Print out that message on the main thread.
*/
function partThree(){
return;
}
/**
* Create a future that _returns_ a message to print out after 5 seconds.
* Wait for a 3 second timeout before returning a default value.
* Print out that message on the main thread.
*/
function partFour(){
return;
}
/**
* Create a future that _returns_ a message to print out after 5 seconds.
* Wait for a 3 second timeout. Do not return a default value.
* See what happens on the main thread
* - when you do not wait for the future to complete?
* - when you wait for the future to complete?
*/
function partFive(){
return;
}
function run(){
print.blueLine( "Running all `01-intro-to-futures` exercises" ).toConsole();
print
.yellowLine( "Press Ctrl-C to exit" )
.line()
.toConsole();
partOne();
partTwo();
partThree();
partFour();
partFive();
while ( true ) {
sleep( 100 );
}
}
}