|
// retoor <retoor@molodetz.nl>
|
|
|
|
import "scheduler" for Scheduler
|
|
import "timer" for Timer
|
|
import "web" for SessionStore
|
|
|
|
var store = SessionStore.new()
|
|
var results = []
|
|
var taskCount = 5
|
|
|
|
for (i in 0...taskCount) {
|
|
var index = i
|
|
Scheduler.add {
|
|
var session = store.create()
|
|
session["task"] = index
|
|
store.save(session)
|
|
results.add({"id": session.id, "index": index})
|
|
}
|
|
}
|
|
|
|
System.print(results.count) // expect: 0
|
|
|
|
Timer.sleep(50)
|
|
|
|
System.print(results.count) // expect: 5
|
|
|
|
var uniqueIds = {}
|
|
for (r in results) {
|
|
uniqueIds[r["id"]] = true
|
|
}
|
|
System.print(uniqueIds.count) // expect: 5
|
|
|
|
var hasAll = true
|
|
for (i in 0...5) {
|
|
var found = false
|
|
for (r in results) {
|
|
if (r["index"] == i) found = true
|
|
}
|
|
if (!found) hasAll = false
|
|
}
|
|
System.print(hasAll) // expect: true
|