<commit_before>using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Framework.DesignTimeHost.Models;
using Microsoft.Framework.Logging;
using OmniSharp.Models;
using OmniSharp.Options;
using OmniSharp.Services;

namespace OmniSharp.Dnx
{
    public class PackagesRestoreTool
    {
        private readonly OmniSharpOptions _options;
        private readonly ILogger _logger;
        private readonly IEventEmitter _emitter;
        private readonly DnxContext _context;
        private readonly DnxPaths _paths;
        private readonly object _lock;
        private readonly IDictionary<string, object> _projectLocks;
        private readonly SemaphoreSlim _semaphore;

        public PackagesRestoreTool(OmniSharpOptions options, ILoggerFactory logger, IEventEmitter emitter, DnxContext context, DnxPaths paths)
        {
            _options = options;
            _logger = logger.CreateLogger<PackagesRestoreTool>();
            _emitter = emitter;
            _context = context;
            _paths = paths;
            _lock = new object();
            _projectLocks = new Dictionary<string, object>();
            _semaphore = new SemaphoreSlim(Environment.ProcessorCount / 2);
        }

        public void Run(Project project)
        {
            if (!_options.Dnx.EnablePackageRestore)
            {
                return;
            }

            Task.Factory.StartNew(() =>
            {
                object projectLock;
                lock (_lock)
                {
                    if (!_projectLocks.TryGetValue(project.Path, out projectLock))
                    {
                        projectLock = new object();
                        _projectLocks.Add(project.Path, projectLock);
                    }
                    else
                    {
                        return;
                    }
                }<commit_msg>Fix package restore not running on single processor machines.<commit_after>using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Framework.DesignTimeHost.Models;
using Microsoft.Framework.Logging;
using OmniSharp.Models;
using OmniSharp.Options;
using OmniSharp.Services;

namespace OmniSharp.Dnx
{
    public class PackagesRestoreTool
    {
        private readonly OmniSharpOptions _options;
        private readonly ILogger _logger;
        private readonly IEventEmitter _emitter;
        private readonly DnxContext _context;
        private readonly DnxPaths _paths;
        private readonly object _lock;
        private readonly IDictionary<string, object> _projectLocks;
        private readonly SemaphoreSlim _semaphore;

        public PackagesRestoreTool(OmniSharpOptions options, ILoggerFactory logger, IEventEmitter emitter, DnxContext context, DnxPaths paths)
        {
            _options = options;
            _logger = logger.CreateLogger<PackagesRestoreTool>();
            _emitter = emitter;
            _context = context;
            _paths = paths;
            _lock = new object();
            _projectLocks = new Dictionary<string, object>();
            _semaphore = new SemaphoreSlim(GetNumConcurrentRestores());
        }

        static int GetNumConcurrentRestores()
        {
            int concurrentRestores = Environment.ProcessorCount / 2;
            if (concurrentRestores > 0)
            {
                return concurrentRestores;
            }

            return 1;
        }

        public void Run(Project project)
        {
            if (!_options.Dnx.EnablePackageRestore)
            {
                return;
            }

            Task.Factory.StartNew(() =>
            {
                object projectLock;
                lock (_lock)
                {
                    if (!_projectLocks.TryGetValue(project.Path, out projectLock))
                    {
                        projectLock = new object();
                        _projectLocks.Add(project.Path, projectLock);
                    }
                    else
                    {
                        return;
                    }
                }
{'fraction_non_alphanumeric': 0.06466729147141519, 'fraction_numerical': 0.0009372071227741331, 'mean_word_length': 1.7524177949709865, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3016048', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1006, 'n_words': 251}