초기커밋
This commit is contained in:
35
ServerCore/Sync/AutoLock.cs
Normal file
35
ServerCore/Sync/AutoLock.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace ServerCore;
|
||||
|
||||
//=============================================================================================
|
||||
// 병렬 프로그래밍 환경에서 특정 로직이 동시에 실행되지 않도록 Monitor를 활용하여 보호하는 클래스 이다.
|
||||
//
|
||||
// author : kangms
|
||||
//
|
||||
//=============================================================================================
|
||||
|
||||
public class AutoLock : IDisposable
|
||||
{
|
||||
private readonly object m_lock;
|
||||
|
||||
public AutoLock(object tolockObject)
|
||||
{
|
||||
m_lock = tolockObject;
|
||||
|
||||
Monitor.Enter(m_lock);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Monitor.Exit(m_lock);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user