Пример #1
0
        /// <summary>
        /// The main constructor. It expects an `ISnippets` instance that takes care
        /// of compiling and keeping track of the code Snippets provided by users.
        /// </summary>
        public IQSharpEngine(
            IShellServer shell,
            IOptions <KernelContext> context,
            ILogger <IQSharpEngine> logger,
            IServiceProvider services,
            IConfigurationSource configurationSource,
            IPerformanceMonitor performanceMonitor,
            IShellRouter shellRouter,
            IMetadataController metadataController,
            ICommsRouter commsRouter,
            IEventService eventService
            ) : base(shell, shellRouter, context, logger, services)
        {
            this.performanceMonitor = performanceMonitor;
            performanceMonitor.EnableBackgroundReporting     = true;
            performanceMonitor.OnKernelPerformanceAvailable += (source, args) =>
            {
                logger.LogInformation(
                    "Estimated RAM usage:" +
                    "\n\tManaged: {Managed} bytes" +
                    "\n\tTotal:   {Total} bytes",
                    args.ManagedRamUsed,
                    args.TotalRamUsed
                    );
            };
            performanceMonitor.Start();
            this.configurationSource = configurationSource;
            this.services            = services;
            this.logger             = logger;
            this.metadataController = metadataController;
            this.commsRouter        = commsRouter;
            this.eventService       = eventService;

            // Start comms routers as soon as possible, so that they can
            // be responsive during kernel startup.
            this.AttachCommsListeners();
        }