Skip to content

Commit

Permalink
Merge branch 'release/2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomelli committed Oct 30, 2018
2 parents 8d44c4c + d71811f commit 5012268
Show file tree
Hide file tree
Showing 18 changed files with 525 additions and 60 deletions.
46 changes: 46 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at giacomelli@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
30 changes: 30 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## How to contribute to GeneticSharp

### Did you find a bug?

* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/giacomelli/GeneticSharp/issues).
* If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/giacomelli/GeneticSharp/issues/new?template=bug_report.md).

### Did you write a fix to a bug?

* Open a new GitHub pull request with the fix.
* Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.


### Do you intend to add a new feature or change an existing one?

* Suggest your change in a [new feature request](https://github.com/giacomelli/GeneticSharp/issues/new?template=feature_request.md).
* Do not start writing code until you have collected positive feedback about the change.

### Do you have questions about the source code?
* Take a look on our [wiki](https://github.com/giacomelli/GeneticSharp/wiki).
* Ask on GeneticSharp's [tag](https://stackoverflow.com/questions/tagged/geneticsharp) on Stack Overflow.
* Open a [question](https://github.com/giacomelli/GeneticSharp/issues/new?template=question.md).

### Do you want to contribute to the GeneticSharp documentation?

* Please, contribute directly on our [wiki](https://github.com/giacomelli/GeneticSharp/wiki).

Thanks! :heart: :heart: :heart:

Diego Giacomelli
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ after_build:
- cmd: >-
mkdir .\src\nuget
dotnet pack src/GeneticSharp.Domain/GeneticSharp.Domain.csproj -c release --no-build --output ../nuget /p:PackageVersion=2.0.0
dotnet pack src/GeneticSharp.Domain/GeneticSharp.Domain.csproj -c release --no-build --output ../nuget /p:PackageVersion=2.1.0
dotnet pack src/GeneticSharp.Extensions/GeneticSharp.Extensions.csproj -c release --no-build --output ../nuget /p:PackageVersion=2.0.0
dotnet pack src/GeneticSharp.Extensions/GeneticSharp.Extensions.csproj -c release --no-build --output ../nuget /p:PackageVersion=2.1.0
test_script:
- cmd: dotnet clean src/GeneticSharp.Domain.UnitTests
Expand Down
Binary file added docs/logo/icon-64x64-transparent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/logo/icon-transparent.xcf
Binary file not shown.
1 change: 1 addition & 0 deletions src/GeneticSharp.Domain/GeneticSharp.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<Owners>g1acomell1</Owners>
<PackageLicenseUrl>https://github.com/giacomelli/GeneticSharp/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/giacomelli/GeneticSharp</PackageProjectUrl>
<PackageIconUrl>https://github.com/giacomelli/GeneticSharp/raw/master/docs/logo/icon-64x64-transparent.png</PackageIconUrl>
<PackageReleaseNotes>See changes at https://github.com/giacomelli/GeneticSharp.</PackageReleaseNotes>
<PackageTags>genetic-algorithms geneticsharp genetic algotithms</PackageTags>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/GeneticSharp.Domain/Properties/SolutionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
[assembly: AssemblyConfiguration("Release")]
#endif

[assembly: AssemblyVersion("1.2.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("2.1.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]
1 change: 1 addition & 0 deletions src/GeneticSharp.Extensions/GeneticSharp.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<Owners>g1acomell1</Owners>
<PackageLicenseUrl>https://github.com/giacomelli/GeneticSharp/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/giacomelli/GeneticSharp</PackageProjectUrl>
<PackageIconUrl>https://github.com/giacomelli/GeneticSharp/raw/master/docs/logo/icon-64x64-transparent.png</PackageIconUrl>
<PackageReleaseNotes>See changes at https://github.com/giacomelli/GeneticSharp.</PackageReleaseNotes>
<PackageTags>genetic-algorithms geneticsharp genetic algotithms</PackageTags>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,32 +84,32 @@ public void Stop_ManyTasks_StopAll()
{
var pipeline = "";
var target = new ParallelTaskExecutor();
target.Timeout = TimeSpan.FromMilliseconds(1000);

target.Add(() =>
{
Thread.Sleep(5);
pipeline += "1";
});
target.Add(() =>
{
Thread.Sleep(5);
pipeline += "2";
});
target.Add(() =>
{
Thread.Sleep(5);
pipeline += "3";
});

Parallel.Invoke(
() => Assert.IsTrue(target.Start()),
() =>
{
Thread.Sleep(100);
target.Stop();
});
target.Timeout = TimeSpan.FromMilliseconds(1000);

target.Add(() =>
{
Thread.Sleep(5);
pipeline += "1";
});
target.Add(() =>
{
Thread.Sleep(5);
pipeline += "2";
});
target.Add(() =>
{
Thread.Sleep(5);
pipeline += "3";
});

Parallel.Invoke(
() => Assert.IsTrue(target.Start()),
() =>
{
Thread.Sleep(100);
target.Stop();
});

}

[Test()]
Expand Down Expand Up @@ -145,6 +145,48 @@ public void Stop_Tasks_ShutdownCalled()

Assert.IsFalse(target.IsRunning);
}

[Test()]
public void Start_MaxThreads1_DoNotBlockOtherThreads()
{
var target = new ParallelTaskExecutor
{
MinThreads = 1,
MaxThreads = 1
};

target.Add(() =>
{
});
target.Add(() =>
{
Thread.Sleep(200);
});
target.Add(() =>
{
Thread.Sleep(10);
});


int otherThreadCount = 0;
var otherThread = new System.Timers.Timer(50)
{
AutoReset = true
};
otherThread.Elapsed += (sender, arg) =>
{
otherThreadCount++;
};
otherThread.Start();

Task.Run(() =>
{
target.Start();
}).Wait();

otherThread.Stop();
Assert.GreaterOrEqual(otherThreadCount, 2);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ public ParallelTaskExecutor()
/// <returns>If has reach the timeout false, otherwise true.</returns>
public override bool Start()
{
// Configure the ThreadPool min and max threads number to the define on this instance properties..
ThreadPool.GetMinThreads(out int minWorker, out int minIOC);
ThreadPool.SetMinThreads(MinThreads, minIOC);

ThreadPool.GetMaxThreads(out int maxWorker, out int maxIOC);
ThreadPool.SetMaxThreads(MaxThreads, maxIOC);
SetThreadPoolConfig(out int minWorker, out int minIOC, out int maxWorker, out int maxIOC);

try
{
Expand All @@ -68,22 +63,57 @@ public override bool Start()
}
finally
{
// Rollback ThreadPool previous min and max threads configuration.
ThreadPool.SetMinThreads(minWorker, minIOC);
ThreadPool.SetMaxThreads(maxWorker, maxIOC);

ResetThreadPoolConfig(minWorker, minIOC, maxWorker, maxIOC);
IsRunning = false;
}
}

}

/// <summary>
/// Stops the tasks execution.
/// </summary>
public override void Stop()
public override void Stop()
{
base.Stop();
m_cancellationTokenSource.Cancel();
IsRunning = false;
}
}

/// <summary>
/// Configure the ThreadPool min and max threads number to the define on this instance properties.
/// </summary>
/// <param name="minWorker">Minimum worker.</param>
/// <param name="minIOC">Minimum ioc.</param>
/// <param name="maxWorker">Max worker.</param>
/// <param name="maxIOC">Max ioc.</param>
private void SetThreadPoolConfig(out int minWorker, out int minIOC, out int maxWorker, out int maxIOC)
{
// Do not change values if the new values to min and max threads are lower than already configured on ThreadPool.
ThreadPool.GetMinThreads(out minWorker, out minIOC);

if (MinThreads > minWorker)
{
ThreadPool.SetMinThreads(MinThreads, minIOC);
}

ThreadPool.GetMaxThreads(out maxWorker, out maxIOC);

if (MaxThreads > maxWorker)
{
ThreadPool.SetMaxThreads(MaxThreads, maxIOC);
}
}

/// <summary>
/// Rollback ThreadPool previous min and max threads configuration.
/// </summary>
/// <param name="minWorker">Minimum worker.</param>
/// <param name="minIOC">Minimum ioc.</param>
/// <param name="maxWorker">Max worker.</param>
/// <param name="maxIOC">Max ioc.</param>
private static void ResetThreadPoolConfig(int minWorker, int minIOC, int maxWorker, int maxIOC)
{
ThreadPool.SetMinThreads(minWorker, minIOC);
ThreadPool.SetMaxThreads(maxWorker, maxIOC);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<configuration>
<dllmap dll="libglib-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/libglib-2.0.0.dylib"/>
<dllmap dll="libgobject-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/libgobject-2.0.0.dylib"/>
<dllmap dll="libgdk-win32-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/libgdk-quartz-2.0.0.dylib"/>
<dllmap dll="libgdk_pixbuf-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/libgdk_pixbuf-2.0.0.dylib"/>
<dllmap dll="libglib-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglib-2.0.0.dylib"/>
<dllmap dll="libgobject-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgobject-2.0.0.dylib"/>
<dllmap dll="libgdk-win32-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdk-quartz-2.0.0.dylib"/>
<dllmap dll="libgdk_pixbuf-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdk_pixbuf-2.0.0.dylib"/>
</configuration>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<configuration>
<dllmap dll="libglib-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/libglib-2.0.0.dylib"/>
<dllmap dll="libgobject-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/libgobject-2.0.0.dylib"/>
<dllmap dll="libgthread-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/libgthread-2.0.0.dylib"/>
<dllmap dll="libglib-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglib-2.0.0.dylib"/>
<dllmap dll="libgobject-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgobject-2.0.0.dylib"/>
<dllmap dll="libgthread-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgthread-2.0.0.dylib"/>
</configuration>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<configuration>
<dllmap dll="libglib-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/libglib-2.0.0.dylib"/>
<dllmap dll="libgobject-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/libgobject-2.0.0.dylib"/>
<dllmap dll="libatk-1.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/libatk-1.0.0.dylib"/>
<dllmap dll="libgtk-win32-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/libgtk-quartz-2.0.0.dylib"/>
<dllmap dll="libgdk-win32-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/libgdk-quartz-2.0.0.dylib"/>
<dllmap dll="libglib-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglib-2.0.0.dylib"/>
<dllmap dll="libgobject-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgobject-2.0.0.dylib"/>
<dllmap dll="libatk-1.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libatk-1.0.0.dylib"/>
<dllmap dll="libgtk-win32-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgtk-quartz-2.0.0.dylib"/>
<dllmap dll="libgdk-win32-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdk-quartz-2.0.0.dylib"/>
</configuration>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<configuration>
<dllmap dll="libglib-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/libglib-2.0.0.dylib"/>
<dllmap dll="libgobject-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/libgobject-2.0.0.dylib"/>
<dllmap dll="libpango-1.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/libpango-1.0.0.dylib"/>
<dllmap dll="libpangocairo-1.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/libpangocairo-1.0.0.dylib"/>
<dllmap dll="libglib-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglib-2.0.0.dylib"/>
<dllmap dll="libgobject-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgobject-2.0.0.dylib"/>
<dllmap dll="libpango-1.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libpango-1.0.0.dylib"/>
<dllmap dll="libpangocairo-1.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libpangocairo-1.0.0.dylib"/>
</configuration>
17 changes: 17 additions & 0 deletions src/Samples/Issue40Sample/Issue40Sample.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Issue40Sample", "Issue40Sample\Issue40Sample.csproj", "{EAF93A31-6880-43A9-8DDC-487765E714E9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EAF93A31-6880-43A9-8DDC-487765E714E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EAF93A31-6880-43A9-8DDC-487765E714E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EAF93A31-6880-43A9-8DDC-487765E714E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EAF93A31-6880-43A9-8DDC-487765E714E9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Loading

0 comments on commit 5012268

Please sign in to comment.