public void SetDeploy(Deploy deploy)
{
Action<IList<string>, Deploy> add = (path, d) =>
{
bool set;
do
{
var w = _deployments.Value;
foreach (var t in path)
{
var curPath = t;
if (string.IsNullOrEmpty(curPath))
throw new IllegalActorNameException(string.Format("Actor name in deployment [{0}] must not be empty", d.Path));
if (!ActorPath.IsValidPathElement(t))
{
throw new IllegalActorNameException(
string.Format("Illegal actor name [{0}] in deployment [${1}]. Actor paths MUST: not start with `$`, include only ASCII letters and can only contain these special characters: ${2}.", t, d.Path, new String(ActorPath.ValidSymbols)));
}
}
set = _deployments.CompareAndSet(w, w.Insert(path.GetEnumerator(), d));
} while(!set);
};
var elements = deploy.Path.Split('/').Drop(1).ToList();
add(elements, deploy);
}