text:
> Nexus Artifact Deployer from grunt

[![Build Status](https://travis-ci.org/cthorne66/nexus-deployer.png)](https://travis-ci.org/cthorne66/nexus-deployer)
[![npm version](https://badge.fury.io/js/nexus-deployer.svg)](http://badge.fury.io/js/nexus-deployer)
[![Dependency Status](https://david-dm.org/cthorne66/nexus-deployer.png)](https://david-dm.org/cthorne66/nexus-deployer)
## Getting Started

To install
```shell
npm install nexus-deployer --save-dev
```

From there, you have options

1. Run with Node
2. Run with Gulp
2. Run with Grunt

## Running with Node

```js
var deployer = require('nexus-deployer');

var release = {
    groupId: 'nexus-deployer',
    artifactId: 'nexus-deployer',
    version: '1.0',
    packaging: 'zip',
    auth: {
      username:'admin',
      password:'admin123'
    },
    pomDir: 'build/pom',
    url: 'http://localhost:8081/nexus/content/repositories/releases',
    artifact: 'build/nexus-deployer.zip',
    noproxy: 'localhost',
    cwd: ''
};

deployer.deploy(release, function(){
    // your async call back here
    // done();
});

```

## Running with Gulp

```js
var deployer = require('nexus-deployer');

// dont forget to create a task to actually generate the artifact as assumed
// here with the dependent 'artifacts:generate' task
gulp.task('deploy:artifacts', ['artifacts:generate'], function(callback) {

    var snapshot = {
        groupId: 'nexus-deployer',
        artifactId: 'nexus-deployer',
        version: '1.2-SNAPSHOT',
        packaging: 'zip',
        auth: {
            username:'admin',
            password:'admin123'
        },
        pomDir: 'build/pom',
        url: 'http://localhost:8081/nexus/content/repositories/snapshots',
        artifact: 'build/nexus-deployer.zip',
        noproxy: 'localhost',
        cwd: '',
        quiet: false,
        insecure: true
    };

    deployer.deploy(snapshot, callback);

});
```

## Running with Grunt
This plugin requires Grunt `~0.4.2`

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

```js
grunt.loadNpmTasks('nexus-deployer');
```

## The "nexusDeployer" task

### Overview
In your project's Gruntfile, add a section named `nexusDeployer` to the data object passed into `grunt.initConfig()`.

```js
grunt.initConfig({
  nexusDeployer: {
    release: {
      options: {
		  groupId: "nexus-deployer",
		  artifactId: "nexus-deployer",
		  version: "1.0",
		  packaging: 'zip',
                  classifier: 'dev',
		  auth: {
			username:'admin',
			password:'admin123'
		  },
		  pomDir: 'build/pom',
		  url: 'http://localhost:9220/nexus/content/repositories/releases',
		  artifact: 'build/nexus-deployer.zip',
		  noproxy: 'localhost',
		  cwd: ''
		}
      }
    }
});
```

### Options

#### options.groupId
Type: `String`
Default value: `''`

The group owning the artifact.

#### options.artifactId
Type: `String`
Default value: `''`

The artifact id of the artifact.

#### options.packaging
Type: `String`
Default value: `''`

Type of artifact. eg zip, jar, pom, war etc.

#### options.classifier
Type: `String`
Defaut value: `''`

An optional classifier that can further distinguish between artifacts of the same group, id and version. eg dev, prod etc. (i.e. artifact-1.0-dev.zip, artifact-1.0-prod.zip)

#### options.version
Type: `String`
Default value: `''`

Version of the artifact being uploaded. Ensure you have your versions ending with -SNAPSHOT when an artifact is being uploaded to snapshot repository. Often artifact repositories
have that restriction.

#### options.auth.password
Type: `String`
Default value: `''`

Password to be used for authentication against nexus server

#### options.auth.username
Type: `String`
Default value: `''`

Username to be used for authentication against nexus server

#### options.insecure
Type: `boolean`
Default value: `false`

Accept Self-Signed certificates when connecting over https.

#### options.url
Type: `String`
Default value: `''`

Nexus repository url. Usually /nexus/content/repositories/snapshots or /nexus/content/repositories/releases

#### options.artifact
Type: `String`
Default value: `''`

Artifact to be uploaded. Must be a file.

#### options.noproxy
Type: `String`
Default value: `'127.0.0.1'`

list of comma separated addresses to exclude for which proxy is not applicable. This is a must when running proxy and HTTP_PROXY environment value is set.

#### options.cwd
Type: `String`
Default value: `''`

working directory from which deployer will deploy artifacts.

#### options.parallel
Type: `Boolean`
Default value: `'false'`

Whether to upload artifacts in parallel.

#### options.quiet
Type: `Boolean`
Default value: `'false'`

Chatty flag.

### Usage Examples
Deploy to release repository

```js
grunt.initConfig({
  nexusDeployer: {
    release: {
      options: {
		  groupId: "nexus-deployer",
		  artifactId: "nexus-deployer",
		  version: "1.0",
		  packaging: 'zip',
		  auth: {
			username:'admin',
			password:'admin123'
		  },
		  pomDir: 'build/pom',
		  url: 'http://localhost:8081/nexus/content/repositories/releases',
		  artifact: 'build/nexus-deployer.zip',
		  noproxy: 'localhost',
		  cwd: ''
		}
      }
    }
});
```

Deploy to snapshots repository

```js
grunt.initConfig({
  nexusDeployer: {
    release: {
      options: {
		  groupId: "nexus-deployer",
		  artifactId: "nexus-deployer",
		  version: "1.0-SNAPSHOT",
		  packaging: 'zip',
		  auth: {
			username:'admin',
			password:'admin123'
		  },
		  pomDir: 'build/pom',
		  url: 'http://localhost:8081/nexus/content/repositories/snapshots',
		  artifact: 'build/nexus-deployer.zip',
		  noproxy: 'localhost',
		  cwd: '',
		  parallel:false,
		  quiet: true
		}
      }
    }
});
```

To run
```
grunt nexusDeployer
```

## Release History


text:
using System;
using System.Globalization;
using System.Linq;
using System.Xml.XPath;

namespace SolidServices.Controllerless.WebApi.Description
{
    // NOTE: The code in this file is copy-pasted from the default Web API Visual Studio 2013 template.
    /// <summary>
    /// Allows getting type descriptions based on .NET XML documentation files that are generated by the
    /// C# or VB compiler.
    /// </summary>
    public class XmlDocumentationTypeDescriptionProvider : ITypeDescriptionProvider
    {
        private const string TypeExpression = "/doc/members/member[@name='T:{0}']";

        private XPathNavigator _documentNavigator;

        /// <summary>
        /// Initializes a new instance of the <see cref="XmlDocumentationTypeDescriptionProvider"/> class.
        /// </summary>
        /// <param name="documentPath">The physical path to XML document.</param>
        public XmlDocumentationTypeDescriptionProvider(string documentPath)
        {
            Requires.IsNotNull(documentPath, nameof(documentPath));

            _documentNavigator = new XPathDocument(documentPath).CreateNavigator();
        }

        /// <summary>Gets the type's description or null when there is no description for the given type.</summary>
        /// <param name="type">The type.</param>
        /// <returns>The description of the requested type or null.</returns>
        public string GetDescription(Type type)
        {
            XPathNavigator typeNode = GetTypeNode(type);
            return GetTagValue(typeNode, "summary");
        }

        private XPathNavigator GetTypeNode(Type type)
        {
            string controllerTypeName = GetTypeName(type);
            string selectExpression = String.Format(CultureInfo.InvariantCulture, TypeExpression, controllerTypeName);
            return _documentNavigator.SelectSingleNode(selectExpression);
        }

        private static string GetTagValue(XPathNavigator parentNode, string tagName)
        {
            if (parentNode != null)
            {
                XPathNavigator node = parentNode.SelectSingleNode(tagName);
                if (node != null)
                {
                    return node.Value.Trim();
                }
            }

            return null;
        }

        private static string GetTypeName(Type type)
        {
            string name = type.FullName;
            if (type.IsGenericType)
            {
                // Format the generic type name to something like: Generic{System.Int32,System.String}
                Type genericType = type.GetGenericTypeDefinition();
                Type[] genericArguments = type.GetGenericArguments();
                string genericTypeName = genericType.FullName;

                // Trim the generic parameter counts from the name
                genericTypeName = genericTypeName.Substring(0, genericTypeName.IndexOf('`'));
                string[] argumentTypeNames = genericArguments.Select(t => GetTypeName(t)).ToArray();
                name = String.Format(CultureInfo.InvariantCulture, "{0}{{{1}}}", genericTypeName, String.Join(",", argumentTypeNames));
            }
            if (type.IsNested)
            {
                // Changing the nested type name from OuterType+InnerType to OuterType.InnerType to match the XML documentation syntax.
                name = name.Replace("+", ".");
            }

            return name;
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
package org.knowm.xchange.btcturk.service;

import java.io.IOException;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.knowm.xchange.Exchange;
import org.knowm.xchange.btcturk.dto.BTCTurkOrderMethods;
import org.knowm.xchange.btcturk.dto.BTCTurkOrderTypes;
import org.knowm.xchange.btcturk.dto.BTCTurkPair;
import org.knowm.xchange.btcturk.dto.BTCTurkSort;
import org.knowm.xchange.btcturk.dto.account.BTCTurkUserTransactions;
import org.knowm.xchange.btcturk.dto.marketdata.BTCTurkTicker;
import org.knowm.xchange.btcturk.dto.trade.BTCTurkExchangeResult;
import org.knowm.xchange.btcturk.dto.trade.BTCTurkOpenOrders;
import org.knowm.xchange.btcturk.dto.trade.BTCTurkOrder;
import org.knowm.xchange.currency.CurrencyPair;

/** @author mertguner */
public class BTCTurkTradeServiceRaw extends BTCTurkBaseService {

  public BTCTurkTradeServiceRaw(Exchange exchange) {
    super(exchange);
  }

  public List<BTCTurkOpenOrders> getBTCTurkOpenOrders(CurrencyPair pair) throws IOException {

    return btcTurk.getOpenOrders(
        pair.toString().replace("/", ""),
        exchange.getExchangeSpecification().getApiKey(),
        exchange.getNonceFactory(),
        signatureCreator);
  }

  public List<BTCTurkOpenOrders> getBTCTurkOpenOrders() throws IOException {

    List<BTCTurkOpenOrders> openOrdersRaw = new ArrayList<BTCTurkOpenOrders>();

    for (BTCTurkTicker ticker : btcTurk.getTicker()) {
      for (BTCTurkOpenOrders order : getBTCTurkOpenOrders(ticker.getPair())) {
        openOrdersRaw.add(order);
      }
    }

    return openOrdersRaw;
  }

  public List<BTCTurkUserTransactions> getBTCTurkUserTransactions() throws IOException {

    return btcTurk.getUserTransactions(
        0,
        25,
        BTCTurkSort.SORT_ASCENDING.toString(),
        exchange.getExchangeSpecification().getApiKey(),
        exchange.getNonceFactory(),
        signatureCreator);
  }

  public boolean cancelOrder(String id) throws IOException {
    return btcTurk
        .setCancelOrder(
            id,
            exchange.getExchangeSpecification().getApiKey(),
            exchange.getNonceFactory(),
            signatureCreator)
        .getResult();
  }

  public BTCTurkExchangeResult placeMarketOrder(
      BigDecimal total, CurrencyPair pair, BTCTurkOrderTypes orderTypes) throws IOException {
    return postExchange(
        total, BigDecimal.ZERO, BigDecimal.ZERO, pair, BTCTurkOrderMethods.MARKET, orderTypes);
  }

  public BTCTurkExchangeResult placeLimitOrder(
      BigDecimal amount, BigDecimal price, CurrencyPair pair, BTCTurkOrderTypes orderTypes)
      throws IOException {
    return postExchange(
        amount, price, BigDecimal.ZERO, pair, BTCTurkOrderMethods.LIMIT, orderTypes);
  }

  public BTCTurkExchangeResult placeStopLimitOrder(
      BigDecimal amount,
      BigDecimal price,
      BigDecimal triggerPrice,
      CurrencyPair pair,
      BTCTurkOrderTypes orderTypes)
      throws IOException {
    return postExchange(
        amount, price, triggerPrice, pair, BTCTurkOrderMethods.STOP_LIMIT, orderTypes);
  }

  protected String getLocalizedBigDecimalValue(BigDecimal input) {
    final NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
    numberFormat.setGroupingUsed(true);
    numberFormat.setMaximumFractionDigits(8);
    numberFormat.setMinimumFractionDigits(2);
    return numberFormat.format(input);
  }

  private BTCTurkExchangeResult postExchange(
      BigDecimal total_amount,
      BigDecimal price,
      BigDecimal triggerPrice,
      CurrencyPair pair,
      BTCTurkOrderMethods orderMethod,
      BTCTurkOrderTypes orderTypes)
      throws IOException {

    String[] _zero = getLocalizedBigDecimalValue(BigDecimal.ZERO).split("\\.");
    String[] _price = _zero;
    if (orderMethod.equals(BTCTurkOrderMethods.LIMIT))
      _price = getLocalizedBigDecimalValue(price).split("\\.");

    String[] _triggerPrice = _zero;
    if (orderMethod.equals(BTCTurkOrderMethods.STOP_LIMIT)
        || orderMethod.equals(BTCTurkOrderMethods.STOP_MARKET))
      _triggerPrice = getLocalizedBigDecimalValue(triggerPrice).split("\\.");

    String[] _total = getLocalizedBigDecimalValue(total_amount).split("\\.");
    String[] _amount = _zero;
    if (orderTypes.equals(BTCTurkOrderTypes.Sell)) {
      _amount = getLocalizedBigDecimalValue(total_amount).split("\\.");
      _total = _zero;
    }

    BTCTurkOrder order =
        new BTCTurkOrder(
            orderMethod,
            _price[0],
            _price[1],
            _amount[0],
            _amount[1],
            _total[0],
            _total[1],
            2,
            _triggerPrice[0],
            _triggerPrice[1],
            orderTypes,
            new BTCTurkPair(pair));

    return btcTurk.setOrder(
        order.getPrice(),
        order.getPricePrecision(),
        order.getAmount(),
        order.getAmountPrecision(),
        order.getOrderType().getValue(),
        order.getOrderMethod().getValue(),
        order.getPairSymbol().toString(),
        order.getDenominatorPrecision(),
        order.getTotal(),
        order.getTotalPrecision(),
        order.getTriggerPrice(),
        order.getTriggerPricePrecision(),
        exchange.getExchangeSpecification().getApiKey(),
        exchange.getNonceFactory(),
        signatureCreator);
  }
}


text:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;

namespace YamlDotNet.RepresentationModel
{
    /// <summary>
    /// Represents an YAML document.
    /// </summary>
    [Serializable]
    public class YamlDocument
    {
        /// <summary>
        /// Gets or sets the root node.
        /// </summary>
        /// <value>The root node.</value>
        public YamlNode RootNode { get; private set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="YamlDocument"/> class.
        /// </summary>
        public YamlDocument(YamlNode rootNode)
        {
            RootNode = rootNode;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="YamlDocument"/> class with a single scalar node.
        /// </summary>
        public YamlDocument(string rootNode)
        {
            RootNode = new YamlScalarNode(rootNode);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="YamlDocument"/> class.
        /// </summary>
        internal YamlDocument(IParser parser)
        {
            var state = new DocumentLoadingState();

            parser.Expect<DocumentStart>();

            while (!parser.Accept<DocumentEnd>())
            {
                Debug.Assert(RootNode == null);
                RootNode = YamlNode.ParseNode(parser, state);

                if (RootNode is YamlAliasNode)
                {
                    throw new YamlException();
                }
            }

            state.ResolveAliases();

            parser.Expect<DocumentEnd>();
        }

        /// <summary>
        /// Visitor that assigns anchors to nodes that are referenced more than once.
        /// Existing anchors are preserved as much as possible.
        /// </summary>
        private class AnchorAssigningVisitor : YamlVisitorBase
        {
            private readonly HashSet<string> existingAnchors = new HashSet<string>();
            /// <summary>
            /// Key: Node, Value: IsDuplicate
            /// </summary>
            private readonly Dictionary<YamlNode, bool> visitedNodes = new Dictionary<YamlNode, bool>();

            public void AssignAnchors(YamlDocument document)
            {
                existingAnchors.Clear();
                visitedNodes.Clear();

                document.Accept(this);

                var random = new Random();
                foreach (var visitedNode in visitedNodes)
                {
                    if (visitedNode.Value)
                    {
                        string anchor;
                        // If the existing anchor is not already used, we can have it
                        if (!string.IsNullOrEmpty(visitedNode.Key.Anchor) && !existingAnchors.Contains(visitedNode.Key.Anchor))
                        {
                            anchor = visitedNode.Key.Anchor;
                        }
                        else
                        {
                            do
                            {
                                anchor = random.Next().ToString(CultureInfo.InvariantCulture);
                            } while (existingAnchors.Contains(anchor));
                        }

                        existingAnchors.Add(anchor);
                        visitedNode.Key.Anchor = anchor;
                    }
                }
            }

            /// <summary>
            /// Returns whether the visited node is a duplicate.
            /// </summary>
            private bool VisitNodeAndFindDuplicates(YamlNode node)
            {
                bool isDuplicate;
                if (visitedNodes.TryGetValue(node, out isDuplicate))
                {
                    if (!isDuplicate)
                    {
                        visitedNodes[node] = true;
                    }
                    return !isDuplicate;
                }
                else
                {
                    visitedNodes.Add(node, false);
                    return false;
                }
            }

            public override void Visit(YamlScalarNode scalar)
            {
                VisitNodeAndFindDuplicates(scalar);
            }

            public override void Visit(YamlMappingNode mapping)
            {
                if (!VisitNodeAndFindDuplicates(mapping))
                    base.Visit(mapping);
            }

            public override void Visit(YamlSequenceNode sequence)
            {
                if (!VisitNodeAndFindDuplicates(sequence))
                    base.Visit(sequence);
            }
        }

        private void AssignAnchors()
        {
            var visitor = new AnchorAssigningVisitor();
            visitor.AssignAnchors(this);
        }

        internal void Save(IEmitter emitter, bool assignAnchors = true)
        {
            if (assignAnchors)
            {
                AssignAnchors();
            }

            emitter.Emit(new DocumentStart());
            RootNode.Save(emitter, new EmitterState());
            emitter.Emit(new DocumentEnd(false));
        }

        /// <summary>
        /// Accepts the specified visitor by calling the appropriate Visit method on it.
        /// </summary>
        /// <param name="visitor">
        /// A <see cref="IYamlVisitor"/>.
        /// </param>
        public void Accept(IYamlVisitor visitor)
        {
            visitor.Visit(this);
        }

        /// <summary>
        /// Gets all nodes from the document.
        /// <see cref="MaximumRecursionLevelReachedException"/> is thrown if an infinite recursion is detected.
        /// </summary>
        public IEnumerable<YamlNode> AllNodes
        {
            get
            {
                return RootNode.AllNodes;
            }
        }
    }
}


text:
<?php

namespace App\Modules\Roles\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreRole extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $requiredOrNullable = request()->isMethod('PATCH') ? 'nullable' : 'required' . '';
        return [
            'name' => $requiredOrNullable . '|string|max:100|unique:roles,name,' . $this->route('id')
        ];
    }
}


text: This is for baidutask&year=2016&season=spring


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright 2014 Fernando Rincon Martin <frm.rincon@gmail.com>

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<artifactId>org.openeos.assembly.eclipse-derby-all</artifactId>
	<packaging>pom</packaging>

	<parent>
		<groupId>org.openeos</groupId>
		<artifactId>org.openeos.assembly</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>

	<build>
		<plugins>
			<plugin>
				<groupId>org.ops4j</groupId>
				<artifactId>maven-pax-plugin</artifactId>
				<version>1.5</version>
				<configuration>
					<osgi.framework.extensions>org.eclipse.equinox.weaving.adaptors,org.eclipse.equinox.weaving.hooks,org.eclipse.equinox.service.weaving</osgi.framework.extensions>
                                        <!-- <profiles>web</profiles> -->
					<provision>
						<param>--platform=equinox</param>
						<param>--log=debug</param>
<!--
                                                <param><![CDATA[vmo=-Declipse.ignoreApp=true -Dosgi.framework.extensions=org.eclipse.equinox.weaving.hook -Dorg.aspectj.weaver.showWeaveInfo=true -Dorg.aspectj.osgi.verbose=true -Daj.weaving.verbose=true -Dorg.eclipse.equinox.http.jetty.http.port=8080 -Dequinox.ds.print=flase -Dequinox.ds.debug=false -Dlogback.configurationFile=${project.basedir}/conf/logback.xml]]></param>
-->
						<param><![CDATA[--vmo=-Dorg.eclipse.equinox.http.jetty.http.port=8080 -Dosgi.resolveOptional=true -Dosgi.framework.extensions=org.eclipse.equinox.weaving.hook -Dlogback.configurationFile=${project.basedir}/conf/logback.xml -Dorg.aspectj.weaver.showWeaveInfo=true -Dorg.aspectj.osgi.verbose=true -Daj.weaving.verbose=true -Dlogback.statusListenerClass=ch.qos.logback.core.status.OnConsoleStatusListener -Xdebug -Xrunjdwp:transport=dt_socket,address=8998,server=y,suspend=n]]></param>
						<param>scan-dir:${project.basedir}/plugins@2</param>
						<param>scan-dir:${project.basedir}/plugins-nostart@nostart</param>
						<param>mvn:org.eclipse.gemini.blueprint/gemini-blueprint-extender/1.0.2.RELEASE@2</param>
						<param>mvn:org.liquibase/liquibase-osgi/2.0.5@2</param>
						<param>mvn:org.openeos/org.openeos.ds.derby/${project.version}@3</param>
						<param>mvn:org.openeos/org.openeos.hibernate/${project.version}@4</param>
						<param>mvn:org.openeos/org.openeos.liquibase.extender/${project.version}@3</param>
						<param>--log=DEBUG</param>
						<param>--bundleStartLevel=5</param>
						<param>--startLevel=5</param>
						<param>--bootDelegation=org.eclipse.equinox.weaving.adaptors,org.eclipse.equinox.weaving.hooks,org.eclipse.equinox.service.weaving,org.xml.sax.helpers,org.xml.sax</param>
						<param>--systemPackages=org.eclipse.equinox.service.weaving</param>
						<param>--bcp/a=file://${project.basedir}/plugins-nostart/org.eclipse.equinox.weaving.hook_${eclipse.weaving.hook.version}.jar</param>
<!--
                                                <param>scan-bundle:file://${project.basedir}/plugins/org.aspectj.runtime_1.7.0.20120703164200</param>
                                                <param>scan-bundle:file://${project.basedir}/plugins/org.aspectj.weaver_1.7.0.20120703164200</param>
-->
					</provision>
				</configuration>
			</plugin>
		</plugins>
	</build>

</project>


text:
				<button type="button" class="  close-p"  >×</button>

Roles

					<form class="form-horizontal" role="form">
						<fieldset>
							<legend>Allowed Modules</legend>

								<%=this.getModules()%>

						</fieldset>
					</form>

					<button type="button" class="btn btn-gray close-p"
						 >Close</button>
					<button type="button" class="btn btn-green save-p">Save
						changes</button>


text:
package com.mvpotter.kladrapi.request;

/**
 * KLADR district request.
 */
public class DistrictRequest extends AbstractQueryWithTypeRequest {

    /**
     * Constructor.
     *
     * @param query district query
     */
    public DistrictRequest(final String query) {
        super(query, ContentType.DISTRICT);
    }

}


text:
layout: post
title: Online Machine Learning
subtitle:
author: Bin Li
tags: [Machine Learning]
image:
comments: true
published: false
---

记录机器学习模型上线的一些过程。

## References
1. [机器学习算法线上部署方法](https://zhuanlan.zhihu.com/p/23382412)


text:
- git clone https://github.com/ryanfs/phase-0-gps-1
  - pulls the repo down from GitHub to your local machine
- git checkout master
  - moving to the branch that is being checked out, giving you access to those files locally
- touch awesome_page.md
  - creates this markdown file
- git add .
  - stages everything in that directory for a commit (since it's git add 'dot')
- git commit -m "create an empty markdown file - first commit"
  - sends your files into your git repo
- git push origin master
  - sends your local git repo up to GitHub
- ls
  - displays all of the files/folders in the current directory
- pwd
  - show my current file path
- git checkout -b add-command-log
  - creates a new branch, then puts you onto that branch
- cd
  - moves up and down the file path


text:
#ifndef WebDebuggerAgent_h
#define WebDebuggerAgent_h

#if ENABLE(INSPECTOR)

#include <inspector/agents/InspectorDebuggerAgent.h>

namespace WebCore {

class InstrumentingAgents;
typedef String ErrorString;

class WebDebuggerAgent : public Inspector::InspectorDebuggerAgent {
    WTF_MAKE_NONCOPYABLE(WebDebuggerAgent);
    WTF_MAKE_FAST_ALLOCATED;
public:
    WebDebuggerAgent(Inspector::InjectedScriptManager*, InstrumentingAgents*);
    virtual ~WebDebuggerAgent() { }

protected:
    virtual void enable() override;
    virtual void disable(bool isBeingDestroyed) override;

    InstrumentingAgents* m_instrumentingAgents;
};

} // namespace WebCore

#endif // ENABLE(INSPECTOR)

#endif // !defined(WebDebuggerAgent_h)


text:
package org.springframework.cloud.stream.function;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

import org.junit.jupiter.api.Test;

import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.stream.binder.test.InputDestination;
import org.springframework.cloud.stream.binder.test.OutputDestination;
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.GenericMessage;

import static org.assertj.core.api.Assertions.assertThat;

/**
 *
 * @author Oleg Zhurakousky
 *
 */
public class ScenarioTests {

	@Test
	void test2106() {
		try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration
				.getCompleteConfiguration(ConsumerConfiguration.class))
						.web(WebApplicationType.NONE).run(
								"--spring.cloud.function.definition=consume;echo",
								"--spring.cloud.stream.bindings.consume-in-0.destination=input",
								"--spring.cloud.stream.bindings.echo-in-0.destination=echoin",
								"--spring.cloud.stream.bindings.echo-out-0.destination=echoout",
								"--spring.jmx.enabled=false")) {

			ConsumerConfiguration configuration = context.getBean(ConsumerConfiguration.class);

			OutputDestination output = context.getBean(OutputDestination.class);

			StreamBridge bridge = context.getBean(StreamBridge.class);
			bridge.send("input", "destination");
			bridge.send("input", "destination");
			bridge.send("input", "destination");

			bridge.send("consume-in-0", "hello");
			bridge.send("consume-in-0", "hello");
			bridge.send("consume-in-0", "hello");

			bridge.send("echoin", "hello");
			bridge.send("echoin", "hello");
			bridge.send("echoin", "hello");

			assertThat(configuration.destinationCounter).isEqualTo(3);
			assertThat(configuration.bindingCounter).isEqualTo(3);

			assertThat(output.receive(1000, "echoout")).isNotNull();
			assertThat(output.receive(1000, "echoout")).isNotNull();
			assertThat(output.receive(1000, "echoout")).isNotNull();
			assertThat(output.receive(1000, "echoout")).isNull();
		}
	}

	@Test
	void testComposingSupplierWuthTypelessMessageFunction() throws Exception {
		try (ConfigurableApplicationContext context = new SpringApplicationBuilder(
				TestChannelBinderConfiguration.getCompleteConfiguration(SupplierConfiguration.class))
						.web(WebApplicationType.NONE)
						.run("--spring.jmx.enabled=false",
								"--spring.cloud.function.definition=messageSupplier|messageFunction")) {

			OutputDestination output = context.getBean(OutputDestination.class);
			assertThat(output.receive(1000, "messageSuppliermessageFunction-out-0")).isNotNull();
			assertThat(output.receive(1200, "messageSuppliermessageFunction-out-0")).isNotNull();
			assertThat(output.receive(1300, "messageSuppliermessageFunction-out-0")).isNotNull();
		}
	}

	@Test
	void test2107() {
		try (ConfigurableApplicationContext context = new SpringApplicationBuilder(
				TestChannelBinderConfiguration.getCompleteConfiguration(FunctionReturningNullConfiguration.class))
						.web(WebApplicationType.NONE)
						.run("--spring.jmx.enabled=false",
								"--spring.cloud.function.definition=uppercase")) {

			InputDestination input = context.getBean(InputDestination.class);
			input.send(new GenericMessage<byte[]>("a".getBytes()), "uppercase-in-0");
			OutputDestination output = context.getBean(OutputDestination.class);
			assertThat(new String(output.receive(2000, "uppercase-out-0").getPayload())).isEqualTo("a");
			input.send(new GenericMessage<byte[]>("b".getBytes()), "uppercase-in-0");
			assertThat(output.receive(2000, "uppercase-out-0")).isNull();
		}
	}

	@Test
	void test2113() {
		try (ConfigurableApplicationContext context = new SpringApplicationBuilder(
				TestChannelBinderConfiguration.getCompleteConfiguration(TestConfiguration.class))
						.web(WebApplicationType.NONE)
						.run("--spring.jmx.enabled=false",
								"--spring.cloud.function.definition=genericTypeFunction")) {

			InputDestination input = context.getBean(InputDestination.class);
			OutputDestination output = context.getBean(OutputDestination.class);

			input.send(new GenericMessage<byte[]>("hello".getBytes()), "genericTypeFunction-in-0");
			assertThat(new String(output.receive(1000, "genericTypeFunction-out-0").getPayload())).isEqualTo("hello_hello");
		}
	}

	@EnableAutoConfiguration
	@Configuration
	public static class TestConfiguration {
		@SuppressWarnings("unchecked")
		@Bean
		public <I, O> Function<I, O> genericTypeFunction() {
			return v -> {
				return (O) ("hello_" + new String((byte[]) v));
			};
		}
	}

	@EnableAutoConfiguration
	@Configuration
	public static class SupplierConfiguration {
		@Bean
		public Supplier<Message<?>> messageSupplier() {
			return () -> new GenericMessage<>("10/27/20 07:20:01");
		}
		@Bean
		public Function<Message<?>, Message<?>> messageFunction() {
			return message -> {
				return message;
			};
		}

	}

	@EnableAutoConfiguration
	@Configuration
	public static class FunctionReturningNullConfiguration {
		@Bean
		public Function<String, String> uppercase() {
			return v -> {
				if ("a".equals(v)) {
					return v;
				}
				else {
					return null;
				}
			};
		}
	}

	@EnableAutoConfiguration
	public static class ConsumerConfiguration {

		private int destinationCounter;

		private int bindingCounter;

		@Bean
		public Consumer<String> consume() {
			return v -> {
				if (v.equals("destination")) {
					destinationCounter++;
				}
				else {
					bindingCounter++;
				}
			};
		}

		@Bean
		public Function<String, String> echo() {
			return v -> v;
		}
	}
}


text:
<!DOCTYPE html>

  <meta charset="utf-8">
  <title>Hugo Zen Style Guide</title>

  <meta name="description" content="">
  <meta name="generator" content="kss-node">
  <meta name="viewport" content="width=device-width">

  <link rel="stylesheet" href="kss-assets/kss.css">
  <link rel="stylesheet" href="../static/css/styles.css">
<link rel="stylesheet" href="../static/css/style-guide/chroma-kss-styles.css">
<link rel="stylesheet" href="../static/css/style-guide/kss-only.css">

Hugo Zen Style Guide

          0Overview

          1Colors and Sass

                1.1Colors

                1.2Initialization partial

                1.33rd party libraries

                1.4Variables

                1.4.1Breakpoints

                1.4.2Browser support

                1.4.3Font faces, stacks and sizes.

                1.4.4Zen grids

                1.4.5Miscellaneous variables

                1.5Functions

                1.6Mixins

                1.6.1clearfix()

                1.6.2image-url()

                1.6.3rtl()

                1.6.4visually-hidden()

                1.6.5visually-hidden--focusable()

                1.6.6visually-hidden--off()

          2Defaults

          3forms

          4Layouts

          5Components

          6Navigation

              1

                sass

            Colors and Sass

Documentation for colors and Sass mixins and variables.

          Source: styles.scss, line 8


text:
gApp.filter('truncate', function () {
    return function (text, length, end) {
        if (isNaN(length)) {
            length = 100;
        }

        if (end === undefined) {
            end = "...";
        }

        if (text.length <= length || text.length - end.length <= length) {
            return text;
        } else {
            return String(text).substring(0, length - end.length) + end;
        }
    };
});

// replace \n by

gApp.filter('newlines', function () {
    return function (text) {
        return text.replace("\n", "
");
    };
});

// tell angular that an output is safe
gApp.filter('safe', function ($sce) {
    return function (val) {
        return $sce.trustAsHtml(val);
    };
});

gApp.filter('stripHTML', function ($sce) {
    return function (html) {
        try {
            var doc = document.implementation.createHTMLDocument();
            var body = doc.createElement('div');
            body.innerHTML = html;
            return body.textContent||body.innerText;
        } catch(e) {
            return "";
        }
    };
});

// Filter templates by tags
gApp.filter('tagFilter', function (TemplateService) {
    return function (templates, filterTags) {
        if (filterTags && filterTags.length) {
            return _.filter(templates, function (t) {
                tags = TemplateService.tags(t);
                return _.intersection(filterTags, tags).length === filterTags.length;
            });
        } else {
            return templates;
        }
    };
});

// Filter templates by sharing setting
gApp.filter('sharingFilter', function () {
    return function (templates, sharing_setting) {
        if (sharing_setting != 'all' && sharing_setting != 'tag') {
            var private = sharing_setting == 'private';
            var nosync = private ? 1 : 0;
            return _.filter(templates, function (t) {
                if (private) { return t.private === private || t.nosync === nosync; }
                return t.private === private;
            });
        } else {
            return templates;
        }
    };
});

gApp.filter('gravatar', function () {
    var cache = {};
    return function(text, defaultText) {
        if (!text) {
            return '';
        }

        if (!cache[text]) {
            defaultText = (defaultText) ? md5(defaultText.toString().toLowerCase()) : '';
            cache[text] = (text) ? md5(text.toString().toLowerCase()) : defaultText;
        }
        return 'https://www.gravatar.com/avatar/' + cache[text] +  '?d=retro';
    };
});


text: __all__ = ['firemodel', 'geodata', 'planning']


text:
package nl.tudelft.ec2interface.sysmonitor;

import org.hyperic.sigar.Mem;
import org.hyperic.sigar.Swap;
import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.cmd.Shell;
import org.hyperic.sigar.cmd.SigarCommandBase;

public class MemoryUsage extends SigarCommandBase {

    public MemoryUsage(Shell shell) {
        super(shell);
    }

    public MemoryUsage() {
        super();
    }

    public void output(String[] args) throws SigarException {
    }

    public MemoryInfo getInfo()
    {
        try {
        	MemoryInfo mInfo = new MemoryInfo();
			Mem mem   = this.sigar.getMem();
			mInfo.setTotalSystemMemory((int) (mem.getTotal()/1024/1024));
			mInfo.setUsedSystemMemory((int) (mem.getUsed()/1024/1024));
			mInfo.setActualSystemMemory((int) (mem.getActualUsed()/1024/1024));
			mInfo.setUsage(mInfo.getUsedSystemMemory()*100/mInfo.getTotalSystemMemory());
			mInfo.setActualUsage(mInfo.getActualSystemMemory()*100/mInfo.getTotalSystemMemory());

			return mInfo;
        } catch (SigarException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	return null;
    }

    public static void main(String[] args) throws Exception {
        new MemoryUsage().getInfo();
    }
}


text:
import initForm from 'ee_else_ce/pages/projects/issues/form';

document.addEventListener('DOMContentLoaded', initForm);


text:
package com.hpe.caf.worker.document.converters;

import com.hpe.caf.worker.document.DocumentWorkerDocument;
import com.hpe.caf.worker.document.DocumentWorkerFailure;
import com.hpe.caf.worker.document.DocumentWorkerFieldEncoding;
import com.hpe.caf.worker.document.DocumentWorkerFieldValue;
import com.hpe.caf.worker.document.model.Document;
import com.hpe.caf.worker.document.model.Failure;
import com.hpe.caf.worker.document.model.Failures;
import com.hpe.caf.worker.document.model.Field;
import com.hpe.caf.worker.document.model.FieldValue;
import com.hpe.caf.worker.document.model.Fields;
import com.hpe.caf.worker.document.model.Subdocuments;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.apache.commons.codec.binary.Base64;

/**
 * This is a utility class which can be used for constructing {@link DocumentWorkerDocument} POJO objects, which can be easily serialised
 * to JSON, from {@link Document} object model objects.
 */
public final class DocumentConverter
{
    private DocumentConverter()
    {
    }

    @Nonnull
    public static DocumentWorkerDocument convert(final Document document)
    {
        final DocumentWorkerDocument documentOut = new DocumentWorkerDocument();
        documentOut.reference = document.getReference();
        documentOut.fields = convert(document.getFields());
        documentOut.failures = convert(document.getFailures());
        documentOut.subdocuments = convert(document.getSubdocuments());

        return documentOut;
    }

    private static Map<String, List<DocumentWorkerFieldValue>> convert(final Fields fields)
    {
        // I don't think there's anything wrong with this code but I re-wrote it just below in a way that I think is slightly simplier,
        // without the groupingBy() for example.
        //
        //final Map<String, List<DocumentWorkerFieldValue>> fieldsOut = fields.stream()
        //    .flatMap(field -> field.getValues().stream())
        //    .collect(Collectors.groupingBy(fieldValue -> fieldValue.getField().getName(),
        //                                   Collectors.mapping(DocumentConverter::convert, Collectors.toList())));

        final Map<String, List<DocumentWorkerFieldValue>> fieldsOut = fields.stream()
            .filter(Field::hasValues)
            .collect(Collectors.toMap(Field::getName,
                                      field -> field.getValues().stream().map(DocumentConverter::convert).collect(Collectors.toList())));

        return fieldsOut.isEmpty()
            ? null
            : fieldsOut;
    }

    @Nonnull
    private static DocumentWorkerFieldValue convert(final FieldValue fieldValue)
    {
        final DocumentWorkerFieldValue fieldValueOut = new DocumentWorkerFieldValue();

        if (fieldValue.isReference()) {
            fieldValueOut.data = fieldValue.getReference();
            fieldValueOut.encoding = DocumentWorkerFieldEncoding.storage_ref;
        } else if (fieldValue.isStringValue()) {
            fieldValueOut.data = fieldValue.getStringValue();
        } else {
            final byte[] data = fieldValue.getValue();
            fieldValueOut.data = Base64.encodeBase64String(data);
            fieldValueOut.encoding = DocumentWorkerFieldEncoding.base64;
        }

        return fieldValueOut;
    }

    private static List<DocumentWorkerFailure> convert(final Failures failures)
    {
        return failures.isEmpty()
            ? null
            : failures.stream().map(DocumentConverter::convert).collect(Collectors.toList());
    }

    @Nonnull
    private static DocumentWorkerFailure convert(final Failure failure)
    {
        final DocumentWorkerFailure failureOut = new DocumentWorkerFailure();
        failureOut.failureId = failure.getFailureId();
        failureOut.failureMessage = failure.getFailureMessage();
        failureOut.failureStack = failure.getFailureStack();

        return failureOut;
    }

    private static List<DocumentWorkerDocument> convert(final Subdocuments subdocuments)
    {
        return subdocuments.isEmpty() ? null : subdocuments
            .stream()
            .map(DocumentConverter::convert)
            .collect(Collectors.toList());
    }
}


text:
import React from 'react';
import { render } from 'react-dom';
import AppContainer from './containers/AppContainer';

render(
  <AppContainer/>,
  document.getElementById('root')
);


text:
class Account < ActiveRecord::Base
  acts_as_tenant(:site)
  attr_accessible :active, :account_number, :title, :address, :city, :province_or_state, :zip_or_postal_code, :billing_email, :main_contact_name, :main_contact_phone, :main_contact_fax, :main_contact_email, :sales_rep_id
  belongs_to :site
  belongs_to :sales_rep
  has_many :lines, :dependent => :destroy, :order => '`type_of_line`, `use`, `number`'
  has_many :other_services, :dependent => :destroy
  has_many :adjustments, :dependent => :destroy
  has_many :bills, :dependent => :destroy
  has_and_belongs_to_many :taxes
  validates_presence_of :account_number
  validates_uniqueness_to_tenant :account_number
  validates_presence_of :title
  validates_uniqueness_to_tenant :title
  validates_presence_of :address
  validates_presence_of :city
  validates_presence_of :province_or_state
  validates_presence_of :zip_or_postal_code
  validates_numericality_of :main_contact_phone,:allow_blank => true
  validates_length_of :main_contact_phone,:is => 10,:allow_blank => true
  validates_presence_of :sales_rep_id
  validates_numericality_of :main_contact_fax, :allow_blank =>true
  validates_length_of :main_contact_fax,:is => 10,:allow_blank => true
  validates_format_of :billing_email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i,:allow_blank => true
  validates_format_of :main_contact_email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i,:allow_blank => true

  def self.search(search_string)
    if search_string
      find(:all, :conditions => ["title LIKE ? or account_number LIKE ? or lines.number = ?", "%#{search_string}%", "%#{search_string}%", "#{search_string}"], :include => :lines, :order => :title)
    else
      []
    end
  end

end


text:
package org.apache.http.HC4.conn.scheme;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;

import org.apache.http.HC4.conn.scheme.SocketFactory;

/**
 * A {@link SocketFactory SocketFactory} for layered sockets (SSL/TLS).
 * See there for things to consider when implementing a socket factory.
 *
 * @since 4.0
 *
 * @deprecated (4.1)  use {@link SchemeSocketFactory}
 */
@Deprecated
public interface LayeredSocketFactory extends SocketFactory {

    /**
     * Returns a socket connected to the given host that is layered over an
     * existing socket.  Used primarily for creating secure sockets through
     * proxies.
     *
     * @param socket the existing socket
     * @param host the host name/IP
     * @param port the port on the host
     * @param autoClose a flag for closing the underling socket when the created
     * socket is closed
     *
     * @return Socket a new socket
     *
     * @throws IOException if an I/O error occurs while creating the socket
     * @throws UnknownHostException if the IP address of the host cannot be
     * determined
     */
    Socket createSocket(
        Socket socket,
        String host,
        int port,
        boolean autoClose
    ) throws IOException, UnknownHostException;

}


text:
When something is right for Erlang, that means the same for Elixir.

- [5 mils users](https://blog.discordapp.com/scaling-elixir-f9b8e1e7c29b)
- [Why a tech veteran code in Erlang](http://www.evanmiller.org/why-i-program-in-erlang.html)
- [Elixir from Erlang author](https://joearms.github.io/published/2013-05-31-a-week-with-elixir.html)
- [Erlang does distributed computing the right way - from ZeroMQ](http://zeromq.org/whitepapers:multithreading-magic)
- [The Zen of Erlang](https://ferd.ca/the-zen-of-erlang.html)


text:
\hypertarget{class_channels_charts}{}\section{Channels\+Charts Class Reference}
\label{class_channels_charts}\index{Channels\+Charts@{Channels\+Charts}}

Inheritance diagram for Channels\+Charts\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=168pt]{class_channels_charts__inherit__graph}
\end{center}
\end{figure}

Collaboration diagram for Channels\+Charts\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=168pt]{class_channels_charts__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item
\hyperlink{class_channels_charts_a6fd985f15981dde4bca95c029ec3549f}{Channels\+Charts} (float $\ast$$\ast$input, float $\ast$$\ast$output, \hyperlink{class_channels_list}{Channels\+List} $\ast$input\+\_\+channels, \hyperlink{class_channels_list}{Channels\+List} $\ast$output\+\_\+channels, int samples, Q\+Widget $\ast$parent=0)
\begin{DoxyCompactList}\small\item\em \hyperlink{class_channels_charts}{Channels\+Charts} constructor. \end{DoxyCompactList}\item
\mbox{\Hypertarget{class_channels_charts_a459f485f41a6734fe486358502cb8cca}\label{class_channels_charts_a459f485f41a6734fe486358502cb8cca}}
\hyperlink{class_channels_charts_a459f485f41a6734fe486358502cb8cca}{$\sim$\+Channels\+Charts} ()
\begin{DoxyCompactList}\small\item\em \hyperlink{class_channels_charts}{Channels\+Charts} destructor. \end{DoxyCompactList}\end{DoxyCompactItemize}

\subsection{Detailed Description}

Definition at line 103 of file Channels\+List.\+h.

\subsection{Constructor \& Destructor Documentation}
\mbox{\Hypertarget{class_channels_charts_a6fd985f15981dde4bca95c029ec3549f}\label{class_channels_charts_a6fd985f15981dde4bca95c029ec3549f}}
\index{Channels\+Charts@{Channels\+Charts}!Channels\+Charts@{Channels\+Charts}}
\index{Channels\+Charts@{Channels\+Charts}!Channels\+Charts@{Channels\+Charts}}
\subsubsection{\texorpdfstring{Channels\+Charts()}{ChannelsCharts()}}
{\footnotesize\ttfamily Channels\+Charts\+::\+Channels\+Charts (\begin{DoxyParamCaption}\item[{float $\ast$$\ast$}]{input,  }\item[{float $\ast$$\ast$}]{output,  }\item[{\hyperlink{class_channels_list}{Channels\+List} $\ast$}]{input\+\_\+channels,  }\item[{\hyperlink{class_channels_list}{Channels\+List} $\ast$}]{output\+\_\+channels,  }\item[{int}]{samples,  }\item[{Q\+Widget $\ast$}]{parent = {\ttfamily 0} }\end{DoxyParamCaption})}

\begin{DoxyParams}{Parameters}
{\em input} & input signal pointer \\
\hline
{\em output} & output signal pointer \\
\hline
{\em input\+\_\+channels} & input channels object \\
\hline
{\em output\+\_\+channels} & output channels object \\
\hline
{\em samples} & number of samples each channel \\
\hline
{\em parent} & user inteface parent object \\
\hline
\end{DoxyParams}

Definition at line 344 of file Channels\+List.\+cpp.

The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
\item
src/interface/Channels\+List.\+h\item
src/interface/Channels\+List.\+cpp\end{DoxyCompactItemize}


text:
package com.example.lit.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.view.menu.ListMenuItemView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.example.lit.R;

public class ViewFriendActivity extends AppCompatActivity {

    ImageView friendProfileImage;
    TextView friendProfileName;
    TextView friendProfileDescription;
    ListView friendProfileHabits;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view_friend);
    }
}


text:
"""Test utilities for API modules.

Classes:
  ModuleInterfaceTest: Test framework for developing public modules.
"""

# pylint: disable=g-bad-name

import __future__
import json
import os
import types

def AssertDictEqual(expected, actual, testcase):
  """Utility method to dump diffs if the dictionaries aren't equal.

  Args:
    expected: dict, the expected results.
    actual: dict, the actual results.
    testcase: unittest.TestCase, the test case this assertion is used within.
  """
  if expected != actual:
    testcase.assertMultiLineEqual(
        json.dumps(expected, indent=2, sort_keys=True),
        json.dumps(actual, indent=2, sort_keys=True))

class ModuleInterfaceTest(object):
  r"""Test to ensure module interface is carefully constructed.

  A module interface is the set of public objects listed in the module __all__
  attribute.  Modules that will be used by the public should have this interface
  carefully declared.  At all times, the __all__ attribute should have objects
  intended to be used by the public and other objects in the module should be
  considered unused.

  Protected attributes (those beginning with '_') and other imported modules
  should not be part of this set of variables.  An exception is for variables
  that begin and end with '__' which are implicitly part of the interface
  (eg. __name__, __file__, __all__ itself, etc.).

  Modules that are imported in to the tested modules are an exception and may
  be left out of the __all__ definition. The test is done by checking the value
  of what would otherwise be a public name and not allowing it to be exported
  if it is an instance of a module.  Modules that are explicitly exported are
  for the time being not permitted.

  To use this test class a module should define a new class that inherits first
  from ModuleInterfaceTest and then from unittest.TestCase.  No other tests
  should be added to this test case, making the order of inheritance less
  important, but if setUp for some reason is overidden, it is important that
  ModuleInterfaceTest is first in the list so that its setUp method is
  invoked.

  Multiple inheretance is required so that ModuleInterfaceTest is not itself
  a test, and is not itself executed as one.

  The test class is expected to have the following class attributes defined:

    MODULE: A reference to the module that is being validated for interface
      correctness.

  Example:
    Module definition (hello.py):

      import sys

      __all__ = ['hello']

      def _get_outputter():
        return sys.stdout

      def hello():
        _get_outputter().write('Hello\n')

    Test definition:

      import test_util
      import unittest

      import hello

      class ModuleInterfaceTest(module_testutil.ModuleInterfaceTest,
                                unittest.TestCase):

        MODULE = hello

      class HelloTest(unittest.TestCase):
        ... Test 'hello' module ...

      def main(unused_argv):
        unittest.main()

      if __name__ == '__main__':
        app.run()
  """

  def setUp(self):
    """Set up makes sure that MODULE and IMPORTED_MODULES is defined.

    This is a basic configuration test for the test itself so does not
    get it's own test case.
    """
    if not hasattr(self, 'MODULE'):
      self.fail(
          "You must define 'MODULE' on ModuleInterfaceTest sub-class %s." %
          type(self).__name__)

  def testAllExist(self):
    """Test that all attributes defined in __all__ exist."""
    missing_attributes = []
    for attribute in self.MODULE.__all__:
      if not hasattr(self.MODULE, attribute):
        missing_attributes.append(attribute)
    if missing_attributes:
      self.fail('%s of __all__ are not defined in module.' %
                missing_attributes)

  def testAllExported(self):
    """Test that all public attributes not imported are in __all__."""
    missing_attributes = []
    for attribute in dir(self.MODULE):
      if not attribute.startswith('_'):
        if attribute not in self.MODULE.__all__:
          attribute_value = getattr(self.MODULE, attribute)
          if isinstance(attribute_value, types.ModuleType):
            continue
          # pylint: disable=protected-access
          if isinstance(attribute_value, __future__._Feature):
            continue
          missing_attributes.append(attribute)
    if missing_attributes:
      self.fail('%s are not modules and not defined in __all__.' %
                missing_attributes)

  def testNoExportedProtectedVariables(self):
    """Test that there are no protected variables listed in __all__."""
    protected_variables = []
    for attribute in self.MODULE.__all__:
      if attribute.startswith('_'):
        protected_variables.append(attribute)
    if protected_variables:
      self.fail('%s are protected variables and may not be exported.' %
                protected_variables)

  def testNoExportedModules(self):
    """Test that no modules exist in __all__."""
    exported_modules = []
    for attribute in self.MODULE.__all__:
      try:
        value = getattr(self.MODULE, attribute)
      except AttributeError:
        # This is a different error case tested for in testAllExist.
        pass
      else:
        if isinstance(value, types.ModuleType):
          exported_modules.append(attribute)
    if exported_modules:
      self.fail('%s are modules and may not be exported.' % exported_modules)

class DevServerTest(object):

  @staticmethod
  def setUpDevServerEnv(server_software_key='SERVER_SOFTWARE',
                        server_software_value='Development/2.0.0'):
    original_env_value = os.environ.get(server_software_key)
    os.environ[server_software_key] = server_software_value
    return server_software_key, original_env_value

  @staticmethod
  def restoreEnv(server_software_key, server_software_value):
    if server_software_value is None:
      os.environ.pop(server_software_key, None)
    else:
      os.environ[server_software_key] = server_software_value


text:
"""Contains GUI configuration options.
"""
import os

import config
"""Application settings.
"""
APP_SETTINGS = dict(
    title=config.APP_TITLE,
    width=800,
    height=600,
    maximized=False,
    plugins=False,
    developer_mode=config.DEBUG_MODE,)
"""Path to jinja2 templates.
"""
TEMPLATE_PATH = os.path.join(config.APPLICATION_ROOT_DIR, 'ui', 'templates')
"""Path to static files.
"""
STATIC_PATH = os.path.join(config.APPLICATION_ROOT_DIR, 'ui', 'static')


text:
uint32_t convert_unsigned_int_to_unsigned_int(uint32_t x) {
#line 100
  return x;
}

uint8_t convert_unsigned_char_to_unsigned_char(uint8_t x) {
#line 200
  return x;
}

int32_t convert_signed_int_to_signed_int(int32_t x) {
#line 300
  return x;
}

int8_t convert_signed_char_to_signed_char(int8_t x) {
#line 400
  return x;
}

uint8_t convert_unsigned_int_to_unsigned_char(uint32_t x) {
#line 500
  return x;
}

uint32_t convert_unsigned_char_to_unsigned_int(uint8_t x) {
#line 600
  return x;
}

int32_t convert_unsigned_char_to_signed_int(uint8_t x) {
#line 700
  return x;
}

int32_t convert_signed_char_to_signed_int(int8_t x) {
#line 800
  return x;
}

int32_t convert_unsigned_int_to_signed_int(uint32_t x) {
#line 900
  return x;
}

uint32_t convert_signed_int_to_unsigned_int(int32_t x) {
#line 1000
  return x;
}

uint8_t convert_signed_int_to_unsigned_char(int32_t x) {
#line 1100
  return x;
}

uint8_t convert_signed_char_to_unsigned_char(int8_t x) {
#line 1200
  return x;
}

int8_t convert_unsigned_char_to_signed_char(uint8_t x) {
#line 1300
  return x;
}

uint32_t convert_signed_char_to_unsigned_int(int8_t x) {
#line 1400
  return x;
}

int8_t convert_unsigned_int_to_signed_char(uint32_t x) {
#line 1500
  return x;
}

int8_t convert_signed_int_to_signed_char(int32_t x) {
#line 1600
  return x;
}

#line 10111 // !!!

int main() {
  // No bits set.
  convert_unsigned_int_to_unsigned_int(0);
  convert_unsigned_char_to_unsigned_char(0);
  convert_signed_int_to_signed_int(0);
  convert_signed_char_to_signed_char(0);
  convert_unsigned_int_to_unsigned_char(0);
  convert_unsigned_char_to_unsigned_int(0);
  convert_unsigned_char_to_signed_int(0);
  convert_signed_char_to_signed_int(0);
  convert_unsigned_int_to_signed_int(0);
  convert_signed_int_to_unsigned_int(0);
  convert_signed_int_to_unsigned_char(0);
  convert_signed_char_to_unsigned_char(0);
  convert_unsigned_char_to_signed_char(0);
  convert_signed_char_to_unsigned_int(0);
  convert_unsigned_int_to_signed_char(0);
  convert_signed_int_to_signed_char(0);

  // One lowest bit set.
  convert_unsigned_int_to_unsigned_int(1);
  convert_unsigned_char_to_unsigned_char(1);
  convert_signed_int_to_signed_int(1);
  convert_signed_char_to_signed_char(1);
  convert_unsigned_int_to_unsigned_char(1);
  convert_unsigned_char_to_unsigned_int(1);
  convert_unsigned_char_to_signed_int(1);
  convert_signed_char_to_signed_int(1);
  convert_unsigned_int_to_signed_int(1);
  convert_signed_int_to_unsigned_int(1);
  convert_signed_int_to_unsigned_char(1);
  convert_signed_char_to_unsigned_char(1);
  convert_unsigned_char_to_signed_char(1);
  convert_signed_char_to_unsigned_int(1);
  convert_unsigned_int_to_signed_char(1);
  convert_signed_int_to_signed_char(1);

#if defined(V0)
  // All source bits set.
  convert_unsigned_int_to_unsigned_int((uint32_t)UINT32_MAX);
  convert_unsigned_char_to_unsigned_char((uint8_t)UINT8_MAX);
  convert_signed_int_to_signed_int((int32_t)(uint32_t)UINT32_MAX);
  convert_signed_char_to_signed_char((int8_t)UINT8_MAX);
  convert_unsigned_int_to_unsigned_char((uint32_t)UINT32_MAX);
// CHECK-V0: {{.*}}integer-conversion.c:500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 4294967295 (32-bit, unsigned) to type '{{.*}}' (aka 'unsigned char') changed the value to 255 (8-bit, unsigned
  convert_unsigned_char_to_unsigned_int((uint8_t)UINT8_MAX);
  convert_unsigned_char_to_signed_int((uint8_t)UINT8_MAX);
  convert_signed_char_to_signed_int((int8_t)UINT8_MAX);
  convert_unsigned_int_to_signed_int((uint32_t)UINT32_MAX);
// CHECK-V0: {{.*}}integer-conversion.c:900:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 4294967295 (32-bit, unsigned) to type '{{.*}}' (aka 'int') changed the value to -1 (32-bit, signed)
  convert_signed_int_to_unsigned_int((int32_t)(uint32_t)UINT32_MAX);
// CHECK-V0: {{.*}}integer-conversion.c:1000:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -1 (32-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 4294967295 (32-bit, unsigned)
  convert_signed_int_to_unsigned_char((int32_t)(uint32_t)UINT32_MAX);
// CHECK-V0: {{.*}}integer-conversion.c:1100:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -1 (32-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 255 (8-bit, unsigned)
  convert_signed_char_to_unsigned_char((int8_t)UINT8_MAX);
// CHECK-V0: {{.*}}integer-conversion.c:1200:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -1 (8-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 255 (8-bit, unsigned)
  convert_unsigned_char_to_signed_char((uint8_t)UINT8_MAX);
// CHECK-V0: {{.*}}integer-conversion.c:1300:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned char') of value 255 (8-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -1 (8-bit, signed)
  convert_signed_char_to_unsigned_int((int8_t)UINT8_MAX);
// CHECK-V0: {{.*}}integer-conversion.c:1400:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -1 (8-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 4294967295 (32-bit, unsigned)
  convert_unsigned_int_to_signed_char((uint32_t)UINT32_MAX);
// CHECK-V0: {{.*}}integer-conversion.c:1500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 4294967295 (32-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -1 (8-bit, signed)
  convert_signed_int_to_signed_char((int32_t)(uint32_t)UINT32_MAX);
#elif defined(V1)
   // Source 'Sign' bit set.
  convert_unsigned_int_to_unsigned_int((uint32_t)INT32_MIN);
  convert_unsigned_char_to_unsigned_char((uint8_t)INT8_MIN);
  convert_signed_int_to_signed_int((int32_t)(uint32_t)INT32_MIN);
  convert_signed_char_to_signed_char((int8_t)INT8_MIN);
  convert_unsigned_int_to_unsigned_char((uint32_t)INT32_MIN);
// CHECK-V1: {{.*}}integer-conversion.c:500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483648 (32-bit, unsigned) to type '{{.*}}' (aka 'unsigned char') changed the value to 0 (8-bit, unsigned)
  convert_unsigned_char_to_unsigned_int((uint8_t)INT8_MIN);
  convert_unsigned_char_to_signed_int((uint8_t)INT8_MIN);
  convert_signed_char_to_signed_int((int8_t)INT8_MIN);
  convert_unsigned_int_to_signed_int((uint32_t)INT32_MIN);
// CHECK-V1: {{.*}}integer-conversion.c:900:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483648 (32-bit, unsigned) to type '{{.*}}' (aka 'int') changed the value to -2147483648 (32-bit, signed)
  convert_signed_int_to_unsigned_int((int32_t)(uint32_t)INT32_MIN);
// CHECK-V1: {{.*}}integer-conversion.c:1000:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -2147483648 (32-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 2147483648 (32-bit, unsigned)
  convert_signed_int_to_unsigned_char((int32_t)(uint32_t)INT32_MIN);
// CHECK-V1: {{.*}}integer-conversion.c:1100:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -2147483648 (32-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 0 (8-bit, unsigned)
  convert_signed_char_to_unsigned_char((int8_t)INT8_MIN);
// CHECK-V1: {{.*}}integer-conversion.c:1200:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -128 (8-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 128 (8-bit, unsigned)
  convert_unsigned_char_to_signed_char((uint8_t)INT8_MIN);
// CHECK-V1: {{.*}}integer-conversion.c:1300:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned char') of value 128 (8-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -128 (8-bit, signed)
  convert_signed_char_to_unsigned_int((int8_t)INT8_MIN);
// CHECK-V1: {{.*}}integer-conversion.c:1400:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -128 (8-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 4294967168 (32-bit, unsigned)
  convert_unsigned_int_to_signed_char((uint32_t)INT32_MIN);
// CHECK-V1: {{.*}}integer-conversion.c:1500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483648 (32-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to 0 (8-bit, signed)
  convert_signed_int_to_signed_char((int32_t)(uint32_t)INT32_MIN);
// CHECK-V1: {{.*}}integer-conversion.c:1600:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -2147483648 (32-bit, signed) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to 0 (8-bit, signed)
#elif defined(V2)
  // All bits except the source 'Sign' bit are set.
  convert_unsigned_int_to_unsigned_int((uint32_t)INT32_MAX);
  convert_unsigned_char_to_unsigned_char((uint8_t)INT8_MAX);
  convert_signed_int_to_signed_int((int32_t)(uint32_t)INT32_MAX);
  convert_signed_char_to_signed_char((int8_t)INT8_MAX);
  convert_unsigned_int_to_unsigned_char((uint32_t)INT32_MAX);
// CHECK-V2: {{.*}}integer-conversion.c:500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483647 (32-bit, unsigned) to type '{{.*}}' (aka 'unsigned char') changed the value to 255 (8-bit, unsigned)
  convert_unsigned_char_to_unsigned_int((uint8_t)INT8_MAX);
  convert_unsigned_char_to_signed_int((uint8_t)INT8_MAX);
  convert_signed_char_to_signed_int((int8_t)INT8_MAX);
  convert_unsigned_int_to_signed_int((uint32_t)INT32_MAX);
  convert_signed_int_to_unsigned_int((int32_t)(uint32_t)INT32_MAX);
  convert_signed_int_to_unsigned_char((int32_t)(uint32_t)INT32_MAX);
// CHECK-V2: {{.*}}integer-conversion.c:1100:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value 2147483647 (32-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 255 (8-bit, unsigned)
  convert_signed_char_to_unsigned_char((int8_t)INT8_MAX);
  convert_unsigned_char_to_signed_char((uint8_t)INT8_MAX);
  convert_signed_char_to_unsigned_int((int8_t)INT8_MAX);
  convert_unsigned_int_to_signed_char((uint32_t)INT32_MAX);
// CHECK-V2: {{.*}}integer-conversion.c:1500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483647 (32-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -1 (8-bit, signed)
  convert_signed_int_to_signed_char((int32_t)(uint32_t)INT32_MAX);
// CHECK-V2: {{.*}}integer-conversion.c:1600:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value 2147483647 (32-bit, signed) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -1 (8-bit, signed)
#elif defined(V3)
  // All destination bits set.
  convert_unsigned_int_to_unsigned_int((uint32_t)UINT8_MAX);
  convert_unsigned_char_to_unsigned_char((uint8_t)UINT8_MAX);
  convert_signed_int_to_signed_int((int32_t)(uint32_t)UINT8_MAX);
  convert_signed_char_to_signed_char((int8_t)UINT8_MAX);
  convert_unsigned_int_to_unsigned_char((uint32_t)UINT8_MAX);
  convert_unsigned_char_to_unsigned_int((uint8_t)UINT8_MAX);
  convert_unsigned_char_to_signed_int((uint8_t)UINT8_MAX);
  convert_signed_char_to_signed_int((int8_t)UINT8_MAX);
  convert_unsigned_int_to_signed_int((uint32_t)UINT8_MAX);
  convert_signed_int_to_unsigned_int((int32_t)(uint32_t)UINT8_MAX);
  convert_signed_int_to_unsigned_char((int32_t)(uint32_t)UINT8_MAX);
  convert_signed_char_to_unsigned_char((int8_t)UINT8_MAX);
// CHECK-V3: {{.*}}integer-conversion.c:1200:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -1 (8-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 255 (8-bit, unsigned)
  convert_unsigned_char_to_signed_char((uint8_t)UINT8_MAX);
// CHECK-V3: {{.*}}integer-conversion.c:1300:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned char') of value 255 (8-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -1 (8-bit, signed)
  convert_signed_char_to_unsigned_int((int8_t)UINT8_MAX);
// CHECK-V3: {{.*}}integer-conversion.c:1400:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -1 (8-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 4294967295 (32-bit, unsigned)
  convert_unsigned_int_to_signed_char((uint32_t)UINT8_MAX);
// CHECK-V3: {{.*}}integer-conversion.c:1500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 255 (32-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -1 (8-bit, signed)
  convert_signed_int_to_signed_char((int32_t)(uint32_t)UINT8_MAX);
// CHECK-V3: {{.*}}integer-conversion.c:1600:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value 255 (32-bit, signed) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -1 (8-bit, signed)
#elif defined(V4)
  // Destination 'sign' bit set.
  convert_unsigned_int_to_unsigned_int((uint32_t)(uint8_t)INT8_MIN);
  convert_unsigned_char_to_unsigned_char((uint8_t)(uint8_t)INT8_MIN);
  convert_signed_int_to_signed_int((int32_t)(uint32_t)(uint8_t)INT8_MIN);
  convert_signed_char_to_signed_char((int8_t)(uint8_t)INT8_MIN);
  convert_unsigned_int_to_unsigned_char((uint32_t)(uint8_t)INT8_MIN);
  convert_unsigned_char_to_unsigned_int((uint8_t)(uint8_t)INT8_MIN);
  convert_unsigned_char_to_signed_int((uint8_t)(uint8_t)INT8_MIN);
  convert_signed_char_to_signed_int((int8_t)(uint8_t)INT8_MIN);
  convert_unsigned_int_to_signed_int((uint32_t)(uint8_t)INT8_MIN);
  convert_signed_int_to_unsigned_int((int32_t)(uint32_t)(uint8_t)INT8_MIN);
  convert_signed_int_to_unsigned_char((int32_t)(uint32_t)(uint8_t)INT8_MIN);
  convert_signed_char_to_unsigned_char((int8_t)(uint8_t)INT8_MIN);
// CHECK-V4: {{.*}}integer-conversion.c:1200:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -128 (8-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 128 (8-bit, unsigned)
  convert_unsigned_char_to_signed_char((uint8_t)(uint8_t)INT8_MIN);
// CHECK-V4: {{.*}}integer-conversion.c:1300:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned char') of value 128 (8-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -128 (8-bit, signed)
  convert_signed_char_to_unsigned_int((int8_t)(uint8_t)INT8_MIN);
// CHECK-V4: {{.*}}integer-conversion.c:1400:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -128 (8-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 4294967168 (32-bit, unsigned)
  convert_unsigned_int_to_signed_char((uint32_t)(uint8_t)INT8_MIN);
// CHECK-V4: {{.*}}integer-conversion.c:1500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 128 (32-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -128 (8-bit, signed)
  convert_signed_int_to_signed_char((int32_t)(uint32_t)(uint8_t)INT8_MIN);
// CHECK-V4: {{.*}}integer-conversion.c:1600:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value 128 (32-bit, signed) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -128 (8-bit, signed)
#elif defined(V5)
  // All bits except the destination 'sign' bit are set.
  convert_unsigned_int_to_unsigned_int((~((uint32_t)(uint8_t)INT8_MIN)));
  convert_unsigned_char_to_unsigned_char((uint8_t)(uint8_t)INT8_MIN);
  convert_signed_int_to_signed_int((int32_t)(~((uint32_t)(uint8_t)INT8_MIN)));
  convert_signed_char_to_signed_char((int8_t)(uint8_t)INT8_MIN);
  convert_unsigned_int_to_unsigned_char((~((uint32_t)(uint8_t)INT8_MIN)));
// CHECK-V5: {{.*}}integer-conversion.c:500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 4294967167 (32-bit, unsigned) to type '{{.*}}' (aka 'unsigned char') changed the value to 127 (8-bit, unsigned)
  convert_unsigned_char_to_unsigned_int((uint8_t)(uint8_t)INT8_MIN);
  convert_unsigned_char_to_signed_int((uint8_t)(uint8_t)INT8_MIN);
  convert_signed_char_to_signed_int((int8_t)(uint8_t)INT8_MIN);
  convert_unsigned_int_to_signed_int((~((uint32_t)(uint8_t)INT8_MIN)));
// CHECK-V5: {{.*}}integer-conversion.c:900:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 4294967167 (32-bit, unsigned) to type '{{.*}}' (aka 'int') changed the value to -129 (32-bit, signed)
  convert_signed_int_to_unsigned_int((int32_t)(~((uint32_t)(uint8_t)INT8_MIN)));
// CHECK-V5: {{.*}}integer-conversion.c:1000:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -129 (32-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 4294967167 (32-bit, unsigned)
  convert_signed_int_to_unsigned_char((int32_t)(~((uint32_t)(uint8_t)INT8_MIN)));
// CHECK-V5: {{.*}}integer-conversion.c:1100:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -129 (32-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 127 (8-bit, unsigned)
  convert_signed_char_to_unsigned_char((int8_t)(uint8_t)INT8_MIN);
// CHECK-V5: {{.*}}integer-conversion.c:1200:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -128 (8-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 128 (8-bit, unsigned)
  convert_unsigned_char_to_signed_char((uint8_t)(uint8_t)INT8_MIN);
// CHECK-V5: {{.*}}integer-conversion.c:1300:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned char') of value 128 (8-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -128 (8-bit, signed)
  convert_signed_char_to_unsigned_int((int8_t)(uint8_t)INT8_MIN);
// CHECK-V5: {{.*}}integer-conversion.c:1400:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -128 (8-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 4294967168 (32-bit, unsigned)
  convert_unsigned_int_to_signed_char((~((uint32_t)(uint8_t)INT8_MIN)));
// CHECK-V5: {{.*}}integer-conversion.c:1500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 4294967167 (32-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to 127 (8-bit, signed)
  convert_signed_int_to_signed_char((int32_t)(~((uint32_t)(uint8_t)INT8_MIN)));
// CHECK-V5: {{.*}}integer-conversion.c:1600:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -129 (32-bit, signed) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to 127 (8-bit, signed)
#elif defined(V6)
  // Only the source and destination sign bits are set.
  convert_unsigned_int_to_unsigned_int((uint32_t)INT32_MIN);
  convert_unsigned_char_to_unsigned_char((uint8_t)INT8_MIN);
  convert_signed_int_to_signed_int((int32_t)INT32_MIN);
  convert_signed_char_to_signed_char((int8_t)INT8_MIN);
  convert_unsigned_int_to_unsigned_char(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN));
// CHECK-V6: {{.*}}integer-conversion.c:500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483776 (32-bit, unsigned) to type '{{.*}}' (aka 'unsigned char') changed the value to 128 (8-bit, unsigned)
  convert_unsigned_char_to_unsigned_int((uint8_t)INT8_MIN);
  convert_unsigned_char_to_signed_int((uint8_t)INT8_MIN);
  convert_signed_char_to_signed_int((int8_t)INT8_MIN);
  convert_unsigned_int_to_signed_int((uint32_t)INT32_MIN);
// CHECK-V6: {{.*}}integer-conversion.c:900:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483648 (32-bit, unsigned) to type '{{.*}}' (aka 'int') changed the value to -2147483648 (32-bit, signed)
  convert_signed_int_to_unsigned_int((int32_t)INT32_MIN);
// CHECK-V6: {{.*}}integer-conversion.c:1000:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -2147483648 (32-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 2147483648 (32-bit, unsigned)
  convert_signed_int_to_unsigned_char((int32_t)(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
// CHECK-V6: {{.*}}integer-conversion.c:1100:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -2147483520 (32-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 128 (8-bit, unsigned)
  convert_signed_char_to_unsigned_char((int8_t)INT8_MIN);
// CHECK-V6: {{.*}}integer-conversion.c:1200:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -128 (8-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 128 (8-bit, unsigned)
  convert_unsigned_char_to_signed_char((uint8_t)INT8_MIN);
// CHECK-V6: {{.*}}integer-conversion.c:1300:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned char') of value 128 (8-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -128 (8-bit, signed)
  convert_signed_char_to_unsigned_int((int8_t)INT8_MIN);
// CHECK-V6: {{.*}}integer-conversion.c:1400:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -128 (8-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 4294967168 (32-bit, unsigned)
  convert_unsigned_int_to_signed_char((((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
// CHECK-V6: {{.*}}integer-conversion.c:1500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483776 (32-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -128 (8-bit, signed)
  convert_signed_int_to_signed_char((int32_t)(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
// CHECK-V6: {{.*}}integer-conversion.c:1600:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -2147483520 (32-bit, signed) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -128 (8-bit, signed)
#elif defined(V7)
  // All bits except the source and destination sign bits are set.
  convert_unsigned_int_to_unsigned_int((uint32_t)INT32_MAX);
  convert_unsigned_char_to_unsigned_char((uint8_t)INT8_MAX);
  convert_signed_int_to_signed_int((int32_t)INT32_MAX);
  convert_signed_char_to_signed_char((int8_t)INT8_MAX);
  convert_unsigned_int_to_unsigned_char(~(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
// CHECK-V7: {{.*}}integer-conversion.c:500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483519 (32-bit, unsigned) to type '{{.*}}' (aka 'unsigned char') changed the value to 127 (8-bit, unsigned)
  convert_unsigned_char_to_unsigned_int((uint8_t)INT8_MAX);
  convert_unsigned_char_to_signed_int((uint8_t)INT8_MAX);
  convert_signed_char_to_signed_int((int8_t)INT8_MAX);
  convert_unsigned_int_to_signed_int((uint32_t)INT32_MAX);
  convert_signed_int_to_unsigned_int((int32_t)INT32_MAX);
  convert_signed_int_to_unsigned_char((int32_t)(~(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN))));
// CHECK-V7: {{.*}}integer-conversion.c:1100:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value 2147483519 (32-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 127 (8-bit, unsigned)
  convert_signed_char_to_unsigned_char((int8_t)INT8_MAX);
  convert_unsigned_char_to_signed_char((uint8_t)INT8_MAX);
  convert_signed_char_to_unsigned_int((int8_t)INT8_MAX);
  convert_unsigned_int_to_signed_char(~(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
// CHECK-V7: {{.*}}integer-conversion.c:1500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483519 (32-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to 127 (8-bit, signed)
  convert_signed_int_to_signed_char((int32_t)~(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
// CHECK-V7: {{.*}}integer-conversion.c:1600:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value 2147483519 (32-bit, signed) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to 127 (8-bit, signed)
#else
#error Some V* needs to be defined!
#endif

  return 0;
}


text:
package org.opencb.opencga.core.data.source;

import javax.net.ssl.HttpsURLConnection;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class UrlSource implements Source {

    public InputStream getInputStream(String path) {
        try {
            URL url = new URL(path);
            if ("https".equals(url.getProtocol())) {
                HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
                return con.getInputStream();
            } else {
                HttpURLConnection con = (HttpURLConnection) url.openConnection();
                return con.getInputStream();
            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }
}


text:
package org.elasticsearch.plugins;

import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Collections;
import java.util.List;

/**
 * A classloader that is a union over the parent core classloader and classloaders of extended plugins.
 */
public class ExtendedPluginsClassLoader extends ClassLoader {

    /** Loaders of plugins extended by a plugin. */
    private final List<ClassLoader> extendedLoaders;

    private ExtendedPluginsClassLoader(ClassLoader parent, List<ClassLoader> extendedLoaders) {
        super(parent);
        this.extendedLoaders = Collections.unmodifiableList(extendedLoaders);
    }

    @Override
    protected Class<?> findClass(String name) throws ClassNotFoundException {
        for (ClassLoader loader : extendedLoaders) {
            try {
                return loader.loadClass(name);
            } catch (ClassNotFoundException e) {
                // continue
            }
        }
        throw new ClassNotFoundException(name);
    }

    /**
     * Return a new classloader across the parent and extended loaders.
     */
    public static ExtendedPluginsClassLoader create(ClassLoader parent, List<ClassLoader> extendedLoaders) {
        return AccessController.doPrivileged((PrivilegedAction<ExtendedPluginsClassLoader>)
            () -> new ExtendedPluginsClassLoader(parent, extendedLoaders));
    }
}


text:
<!--
- Copyright (c) 2019-2022, Arm Limited and Contributors
-
- SPDX-License-Identifier: Apache-2.0
-
- Licensed under the Apache License, Version 2.0 the "License";
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-->

# Command buffer usage and multi-threaded recording

## Overview

This sample demonstrates how to use and manage secondary command buffers, and how to record them concurrently.

Implementing multi-threaded recording of draw calls can help reduce CPU frame time.

In tile-based renderers, the best approach to split the draw calls is to record them in secondary command buffers.
This way they can all be submitted to the same render pass, and can take advantage of tile local memory.

## Secondary command buffers

Secondary command buffers can inherit the render pass state from a primary command buffer using a [VkCommandBufferInheritanceInfo](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkCommandBufferInheritanceInfo.html) structure which is passed to [vkBeginCommandBuffer](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkBeginCommandBuffer.html) as part of [VkCommandBufferBeginInfo](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkCommandBufferBeginInfo.html), along with the flag `VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT`.
Secondary command buffers may then be recorded concurrently.

The primary command buffer must have used the flag `VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS` in [vkCmdBeginRenderPass](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdBeginRenderPass.html).

Finally, the primary command buffer records [vkCmdExecuteCommands](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdExecuteCommands.html) (before [vkCmdEndRenderPass](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdEndRenderPass.html)) with an array of recorded secondary command buffers to execute.
The sample divides the draw calls for opaque objects based on the slider value. It then submits a separate buffer for transparent objects if any, and finally one for the GUI elements if visible.

## Multi-threaded recording

To record command buffers concurrently, the framework needs to manage resource pools per frame and per thread.
According to the Vulkan Spec:

* [_A command pool must not be used concurrently in multiple threads._](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkCommandPool.html)
* [_The application must not allocate and/or free descriptor sets from the same pool in multiple threads simultaneously._](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkDescriptorPool.html)

In the framework, each frame in the queue (e.g. three frames in case of triple buffering) manages a collection of pools so that each thread can own:

* A command pool
* A descriptor pool cache
* A descriptor set cache
* A buffer pool

This sample then uses a thread pool to push work to multiple threads.
When splitting the draw calls, it is advisable to keep the loads balanced.
The sample allows to change the number of buffers, but if the number of calls is not divisible, the remaining will be evenly spread through other buffers. The average number of draws per buffer is shown on the screen.

Note that since state is not reused across command buffers, a reasonable number of draw calls should be submitted per command buffer, to avoid having the GPU going idle while processing commands.
Therefore having many secondary command buffers with few draw calls can negatively affect performance.
In any case there is no advantage in exceeding the CPU parallelism level i.e. using more command buffers than threads.
Similarly having more threads than buffers may have a performance impact. To keep all threads busy, the sample resizes the thread pool for low number of buffers.
The sample slider can help illustrate these trade-offs and their impact on performance, as shown by the performance graphs.

In this case, a scene with a high number of draw calls (~1800, this number may be found in the [debug window](../../../docs/misc.md#debug-window)) shows a 15% improvement in performance when dividing the workload among 8 buffers across 8 threads:

![Single-threaded](images/single_threading.png)

![Multi-threaded](images/multi_threading.png)

To test the sample, make sure to build it in release mode and without validation layers.
Both these factors can significantly affect the results.

## Recycling strategies

Vulkan provides different ways to manage and allocate command buffers. This sample compares them and demonstrates the best approach.

* [Allocate and Free](#allocate-and-free)
* [Resetting individual command buffers](#resetting-individual-command-buffers)
* [Resetting the command pool](#resetting-the-command-pool)

### Allocate and free

Command buffers are allocated from a command pool with [vkAllocateCommandBuffers](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkAllocateCommandBuffers.html).
They can then be recorded and submitted to a queue for the Vulkan device to execute them.

A possible approach to managing the command buffers for each frame in our application would be to free them once they are executed, using [vkFreeCommandBuffers](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkFreeCommandBuffers.html).

The command pool will not automatically recycle memory from deleted command buffers if the command pool was created without the [RESET_COMMAND_BUFFER_BIT](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkCommandPoolCreateFlagBits.html) flag.
This flag however will force separate internal allocators to be used for each command buffer in the pool, which can increase CPU overhead compared to a single pool reset.

This is the worst-performing method of managing command buffers as it involves a significant CPU overhead for allocating and freeing memory frequently.
The sample shows how to use the framework to follow this approach and profile its performance.

![Allocate and Free](images/allocate_and_free.jpg)

Rather than freeing and re-allocating the memory used by a command buffer, it is more efficient to recycle it for recording new commands.
There are two ways of resetting a command buffer: individually, with [vkResetCommandBuffer](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkResetCommandBuffer.html), or indirectly by resetting the command pool with [vkResetCommandPool](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkResetCommandPool.html).

### Resetting individual command buffers

In order to reset command buffers individually with [vkResetCommandBuffer](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkResetCommandBuffer.html), the pool must have been created with the [RESET_COMMAND_BUFFER_BIT](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkCommandPoolCreateFlagBits.html) flag set.
The buffer will then return to a recordable state and the command pool can reuse the memory it allocated for it.

However frequent calls to [vkResetCommandBuffer](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkResetCommandBuffer.html) are more expensive than a command pool reset.

![Reset Buffers](images/reset_buffers.jpg)

### Resetting the command pool

Resetting the pool with [vkResetCommandPool](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkResetCommandPool.html) automatically resets all the command buffers allocated by it.
Doing this periodically will allow the pool to reuse the memory allocated for command buffers with lower CPU overhead.

To reset the pool the flag [RESET_COMMAND_BUFFER_BIT](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkCommandPoolCreateFlagBits.html) is _not_ required, and it is actually better to avoid it since it prevents it from using a single large allocator for all buffers in the pool thus increasing memory overhead.

![Reset Pool](images/reset_pool.jpg)

### Relative performance

The sample offers the option of recording all drawing operations on a single command buffer, or to divide the opaque object draw calls among a given number of secondary command buffers.
The second method allows multi-threaded command buffer construction.
However the number of secondary command buffers should be kept low since their invocations are expensive.
This sample lets the user adjust the number of command buffers.
Using a high number of secondary command buffers causes the application to become CPU bound and makes the differences between the described memory allocation approaches more pronounced.

All command buffers in this sample are initialized with the [ONE_TIME_SUBMIT_BIT](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkCommandBufferUsageFlagBits.html) flag set. This indicates to the driver that the buffer will not be re-submitted after execution, and allows it to optimize accordingly.
Performance may be reduced if the [SIMULTANEOUS_USE_BIT](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkCommandBufferUsageFlagBits.html) flag is set instead.

This sample provides options to try the three different approaches to command buffer management described above and monitor their efficiency.
This is relatively obvious directly on the device by monitoring frame time.

Since the application is CPU bound, the [Android Profiler](https://developer.android.com/studio/profile/android-profiler) is a helpful tool to analyze the differences in performance. As expected, most of the time goes into the [command pool framework functions](https://github.com/ARM-software/vulkan_best_practice_for_mobile_developers/blob/master/framework/core/command_pool.cpp): `request_command_buffer` and `reset`. These handle the different modes of operation exposed by this sample.

![Android Profiler: Allocate and Free](images/android_profiler_allocate_and_free.png)
_Android Profiler capture: use the Flame Chart to visualize which functions take the most time in the capture. Filter for command buffer functions, and use the tooltips to find out how much time out of the overall capture was used by each function._

Capturing the C++ calls this way allows us to determine how much each function contributed to the overall running time. The results are captured in the table below.

Mode | Request + Reset command buffers (ms) | Total capture (ms) | Contribution
---|---|---|---
Reset pool | 53.3 | 11 877 | 0.45 %
Reset buffers | 140.29 | 12 087 | 1.16 %
Allocate and free | 3 319.25 | 11 513 | 28.8 %

In this application the differences between individual reset and pool reset are more subtle, but allocating and freeing buffers are clearly the bottleneck in the worst performing case.

## Further reading

 * [Multi-threaded recording with multiple render passes](../multithreading_render_passes/README.md)
 * [Command Buffer Allocation and Management](https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/chap6.html#commandbuffer-allocation)
 * [Command Buffer Lifecycle](https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/html/chap5.html#commandbuffers-lifecycle)
 * _"Writing an efficient Vulkan renderer"_ by Arseny Kapoulkine (from "GPU Zen 2: Advanced Rendering Techniques")

## Best-practice summary

**Do**

* Use secondary command buffers to allow multi-threaded render pass construction.
* Minimize the number of secondary command buffer invocations used per frame.
* Set [ONE_TIME_SUBMIT_BIT](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkCommandBufferUsageFlagBits.html) if you are not going to reuse the command buffer.
* Periodically call [vkResetCommandPool()](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkResetCommandPool.html) to release the memory if you are not reusing command buffers.

**Don't**

* Set [RESET_COMMAND_BUFFER_BIT](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkCommandPoolCreateFlagBits.html) if you only need to free the whole pool. If the bit is not set, some implementations might use a single large allocator for the pool, reducing memory management overhead.
* Call [vkResetCommandBuffer()](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkResetCommandBuffer.html) on a high frequency call path.

**Impact**

* Increased CPU load will be incurred with secondary command buffers.
* Increased CPU load will be incurred if command pool creation and command buffer begin flags are not used appropriately.
* Increased CPU overhead if command buffer resets are too frequent.
* Increased memory usage until a manual command pool reset is triggered.

**Debugging**

* Evaluate every use of any command buffer flag other than [ONE_TIME_SUBMIT_BIT](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkCommandBufferUsageFlagBits.html), and review whether it's a necessary use of the flag combination.
* Evaluate every use of [vkResetCommandBuffer()](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkResetCommandBuffer.html) and see if it could be replaced with [vkResetCommandPool()](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkResetCommandPool.html) instead.