-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPythonServerImpl.cs
More file actions
45 lines (41 loc) · 1.38 KB
/
Copy pathPythonServerImpl.cs
File metadata and controls
45 lines (41 loc) · 1.38 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
namespace PythonJobServerLibrary
{
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false, InstanceContextMode = InstanceContextMode.Single)]
public class PythonServerImpl : PythonServerInterface
{
private PythonJobPool jobPool = new PythonJobPool();
public void PostResult(int jobNumber, string jobResult)
{
List<PythonJob> jobList = PythonJobPool.getAllJobs();
for (int i = 0; i < jobList.Count; i++)
{
if (jobList[i].jobNumber == jobNumber)
{
jobList[i].result = jobResult;
break;
}
}
}
public PythonJob RequestJob()
{
List<PythonJob> jobList = PythonJobPool.getAllJobs();
PythonJob send_job = new PythonJob();
for(int i = 0; i < jobList.Count; i++)
{
if (jobList[i].jobRequested == false)
{
jobList[i].jobRequested = true;
send_job = jobList[i];
break;
}
}
return send_job;
}
}
}