mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
.autotest: SpinLock
git-svn-id: svn://ultimatepp.org/upp/trunk@8111 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
00d54c7795
commit
a595a7957c
3 changed files with 39 additions and 0 deletions
26
autotest/SpinLock/SpinLock.cpp
Normal file
26
autotest/SpinLock/SpinLock.cpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include <Core/Core.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
SpinLock data_lock;
|
||||
dword data;
|
||||
|
||||
void AddData()
|
||||
{
|
||||
data_lock.Enter();
|
||||
data = data + 1;
|
||||
data_lock.Leave();
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
RTIMING("Test");
|
||||
{
|
||||
CoWork co;
|
||||
for(int i = 0; i < 10000000; i++)
|
||||
co & callback(AddData);
|
||||
}
|
||||
RDUMP(data);
|
||||
ASSERT(data == 10000000);
|
||||
LOG("================ OK");
|
||||
}
|
||||
9
autotest/SpinLock/SpinLock.upp
Normal file
9
autotest/SpinLock/SpinLock.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
SpinLock.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "SSE2 MT";
|
||||
|
||||
4
autotest/SpinLock/init
Normal file
4
autotest/SpinLock/init
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef _SpinLock_icpp_init_stub
|
||||
#define _SpinLock_icpp_init_stub
|
||||
#include "Core/init"
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue