This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a simple state machine for document workflow with these states: | |
* - draft | |
* - submitted | |
* - under review | |
* - approved or rejected | |
* | |
* The workflow should be: | |
* - draft -> submitted -> under review -> approved or rejected | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a simple state machine for document workflow with these states: | |
* - draft | |
* - submitted | |
* - under review | |
* - approved or rejected | |
* | |
* The workflow should be: | |
* - draft -> submitted -> under review -> approved or rejected | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// implement async queue that won't block the main thread | |
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"sync" | |
"time" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// implement async queue that won't block the main thread | |
// YOUR CODE GOES HERE | |
func main() { | |
queue1 := &Queue{Name: "queue1"} | |
queue1.Add("task1", func() { | |
time.Sleep(time.Duration(random()) * time.Millisecond) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// implement async queue that won't block the main thread | |
// YOUR CODE GOES HERE | |
func main() { | |
queue1 := &Queue{Name: "queue1"} | |
queue1.Add("task1", func() { | |
time.Sleep(time.Duration(random()) * time.Millisecond) | |
}) |