Create and manage locks dynamically in run-time in concurrent software
DynaLock is a library to create and manage locks dynamically in run-time in concurrent software, DynaLock hides all concurrency complexities in distributed systems. DynaLock currently supports Monitor, Semaphore, SemaphoreSlim, AutoResetEvent and ManualResetEvent.
DynaLock is currecntly under development and only supports Monitor, Semaphore, SemaphoreSlim, AutoResetEvent and ManualResetEvent.
-
- Create and manage locker objects dynamically in run-time
-
- Create and manage semaphore objects dynamically in run-time
-
- Create and manage semaphore slim objects dynamically in run-time
-
- Create and manage auto reset event objects dynamically in run-time
-
- Create and manage manual reset event objects dynamically in run-time
-
- Create specific work space for different domains to avoid CPU and resource wasting, improve performance, etc.
- Both DynaLock's Monitor and DynaLock's Semaphore could be injected a context using builder class.
-
- An object that be used to store some info like string values, integers, instances of spesific classes and data structures, so meta-data could be accesses from different threads in current domain.
- Both DynaLock's Monitor and DynaLock's Semaphore could be injected a meta-data object using property.
To install DynaLock in Visual Studio's Package Manager Console:
Install-Package DynaLock -Version 2.5.1
To install in a specific project use:
Install-Package DynaLock -Version 2.5.1 -ProjectName Your_Project_Name
To update package use:
Update-Package DynaLock
To update package in a specific project use:
Update-Package DynaLock -ProjectName Your_Project_Name
Or visit DynaLock's Nuget page to get more information.
DynaLock is easy to use.
using (var monitor = new DynaLock.MonitorBuilder()
.Name("enter_a_unique_name")
.Build()
){
...
monitor.TryEnter();
...
if (monitor.IsLockOwned){
// Some code
} else {
// Some code
}
...
}
And if you've more domain and would like to have individual context per domain, you could use DynaLock like:
DynaLock.Context.Monitor domain1_context = new DynaLock.Context.Monitor()
DynaLock.Context.Monitor domain2_context = new DynaLock.Context.Monitor()
using (var monitor = new DynaLock.MonitorBuilder()
.Context(domain1_context)
.Name("enter_a_unique_name_in_current_domain")
.Build()
){
...
monitor.TryEnter();
...
if (monitor.IsLockOwned){
// Some code
} else {
// Some code
}
...
}
using (var monitor = new DynaLock.MonitorBuilder()
.Context(domain2_context)
.Name("enter_a_unique_name_in_current_domain")
.Build()
){
...
monitor.TryEnter();
...
if (monitor.IsLockOwned){
// Some code
} else {
// Some code
}
...
}
In the above senario, all resources are completely seperated per context and CPU(s) will not be wasted anymore.
Also, you could find working examples in DynaLock.Test project.
Visit CHANGELOG.md to see full change log history of DynaLock
- 2.5.0
- Added SemaphoreSlim to DynaLock
- 2.4.0
- Added flag to DynaLock to give more power to developers
- 2.3.0
- Added ManualResetEvent to DynaLock
- 2.2.0
- Added AutoResetEvent to DynaLock
- 2.0.0
- Added meta-data to contexts
- Refactored and improved the source code
- Added comments to methods, properties and classes
- 1.1.0
- Added Semaphore to DynaLock
- 1.0.0
- Initialized DynaLock
Saeed Aghdam – Linkedin
Distributed under the MIT license. See LICENSE
for more information.
https://github.com/saeedmaghdam/
-
Create your feature branch (
git checkout -b feature/your-branch-name
) -
Commit your changes (
git commit -am 'Add a short message describes new feature'
) -
Push to the branch (
git push origin feature/your-branch-name
) -
Create a new Pull Request