singrdk/base/Applications/ServiceManager/Benchmark/Job.sg

67 lines
1.9 KiB
Plaintext
Raw Normal View History

2008-03-05 09:52:00 -05:00
///////////////////////////////////////////////////////////////////////////////
//
// Microsoft Research Singularity
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// File: Applications\ServiceManager\Benchmark\Job.sg
//
// Note:
//
using System;
using Microsoft.Singularity;
using Microsoft.Singularity.Channels;
using Microsoft.Singularity.Directory;
using Microsoft.Singularity.Services;
namespace Microsoft.Singularity.Applications.ServiceManager
{
internal abstract class Job
{
internal readonly BenchmarkServerInfo! info;
internal Job(BenchmarkServerInfo! info)
{
this.info = info;
}
internal abstract bool Run();
protected bool Bind(out BenchmarkContract.Imp:Ready! ep)
{
bool success = false;
ErrorCode error;
BenchmarkContract.Imp! imp;
BenchmarkContract.Exp! exp;
DirectoryServiceContract.Imp ds;
BenchmarkContract.NewChannel(out imp, out exp);
ds = DirectoryService.NewClientEndpoint();
if (!SdsUtils.Bind(info.ServiceName, ds, exp, out error))
{
Console.WriteLine("Binding failed: {0}\n",
SdsUtils.ErrorCodeToString(error));
success = false;
goto exit;
}
switch receive
{
case imp.Success():
success = true;
break;
case imp.ChannelClosed():
Console.WriteLine("Job: Channel closed.\n");
success = false;
break;
}
exit:
delete ds;
ep = imp;
return success;
}
} // class
}