-
Notifications
You must be signed in to change notification settings - Fork 3
ThreadLocker
Gratt-5r2 edited this page Apr 9, 2022
·
1 revision
void Enter()
- enter to the critical section.
void Leave() - leave from the critical section.\
bool IsLocked() - checks the critical section is locked.
ThreadLocker lck;
int TotalTicksCount = 0;
void foo( int ticks ) {
for( int i = 0; i < ticks; i++ ) {
lck.Enter();
TotalTicksCount++;
lck.Leave();
}
}
void Test() {
int ticksPerThread = 300000;
Array<Thread> threads;
for( int i = 0; i < 16; i++ )
threads.Create( &foo ).Detach( (void*&)ticksPerThread );
Thread::WaitForEnd( threads );
Message::Info( "TotalTicksCount == 300000 * 16 -> " + string( TotalTicksCount == 300000 * 16 ) );
}
- Introduction
- Project hierarchy
- Default functions
- Build options
-
Gothic API
- Base objects
- Models and visuals
- Static and interactive objects
- Animations
- Interface
- Scripts
- Worlds
- Renderer
- Other
- User API
-
Union API
- Hook
- Hook Functions
- Array
- ArraySorted
- Map
- MapArray
- String
- Unicode string
- UTF-8 converter
- RowString
- Console
- Logger
- Message
- Thread
- Event
- Semaphore
- ThreadLocker
- Crc checker
- Options
- Timer
- Union
- VDFS functions
- VirtualFile
- Hooks
- dynamic_cast patch