-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJobQueue.cs
104 lines (93 loc) · 3.05 KB
/
JobQueue.cs
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using System;
using System.Collections.Generic;
namespace TestConsole
{
// 1 queue per application
// TODO: try to implement multiples queues trying to have que same api structure.
public class JobQueue : IJobQueue
{
//Queue.prototype.create = function(type, data)
//static JobQueue()
//{
// JobQueue.start();
//}
//params object[] args
//public List<Func<object, object[]>> queue = new List<Func<object, object[]>>();
//public static List<FuncParams> queue = new List<FuncParams>();
public static Queue<FuncParams> queue = new Queue<FuncParams>();
public static bool ExecuteExpirated = true;
//Multiple queues create/new
//public static void create()
//{
// throw new NotImplementedException();
//}
public static void start()
{
throw new NotImplementedException();
}
public static void define(string name, Action action)
{
throw new NotImplementedException();
}
public static void define(string name, Action action, Action callback)
{
throw new NotImplementedException();
}
public static void define(string name, Action<object> action)
{
throw new NotImplementedException();
}
public static void define<T>(string name, Action<T> p)
{
throw new NotImplementedException();
}
//public static void define(string v, Action p)
//{
// throw new NotImplementedException();
//}
public static void enqueue(Action action)
{
enqueue(null, null, action);
}
public static void enqueue(string jobName)
{
enqueue(jobName, null, null);
}
public static void enqueue(string jobName, object data = null)
{
enqueue( jobName, data, null);
}
public static void enqueue(string jobName, Action action = null)
{
enqueue(jobName, null, action);
}
public static void enqueue(string jobName = null,object data=null, Action action = null)
{
//throw new NotImplementedException();
var func = new Func<object, object[]>(
(args) =>
{
action();
return null;
}
);
//queue.Add();
enqueue(func);
}
public static void enqueue(Func<object, object[]> func, params object[] args )
{
//throw new NotImplementedException();
//var func = new Func<object, object[]>()
FuncParams FuncParams = new FuncParams() { func = func , parameters = args};
//queue.Add(FuncParams);
queue.Enqueue(FuncParams);
//TODO:Use sqlite
}
}
class JobQueueItem
{
public long id { get; set; }
public long time { get; set; }
public string name { get; set; }
}
}