403Webshell
Server IP : 66.29.132.122  /  Your IP : 18.217.141.32
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/opt/cpanel/ea-ruby27/src/passenger-release-6.0.23/test/oxt/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/opt/cpanel/ea-ruby27/src/passenger-release-6.0.23/test/oxt/spin_lock_test.cpp
#include "../tut/tut.h"
#include <boost/bind/bind.hpp>
#include <boost/thread.hpp>
#include <oxt/spin_lock.hpp>

using namespace boost;
using namespace oxt;

namespace tut {
	struct spin_lock_test {
		boost::mutex continue_mutex;
		boost::condition_variable continue_cond;
		bool continue_ok;
		spin_lock lock;
		volatile unsigned int counter;
		
		spin_lock_test() {
			counter = 0;
			continue_ok = false;
		}
		
		void loop_increment(unsigned int inc) {
			{
				boost::mutex::scoped_lock l1(continue_mutex);
				while (!continue_ok) {
					continue_cond.wait(l1);
				}
			}
			
			for (unsigned int i = 0; i < inc; i++) {
				spin_lock::scoped_lock l2(lock);
				counter++;
			}
		}
	};
	
	DEFINE_TEST_GROUP(spin_lock_test);

	TEST_METHOD(1) {
		boost::thread thr1(boost::bind(&spin_lock_test::loop_increment, this, 100000));
		boost::thread thr2(boost::bind(&spin_lock_test::loop_increment, this, 100000));
		boost::thread thr3(boost::bind(&spin_lock_test::loop_increment, this, 100000));
		boost::thread thr4(boost::bind(&spin_lock_test::loop_increment, this, 100000));
		
		{
			boost::mutex::scoped_lock l(continue_mutex);
			continue_ok = true;
			continue_cond.notify_all();
		}
		
		thr1.join();
		thr2.join();
		thr3.join();
		thr4.join();
		
		ensure_equals(counter, 400000u);
	}
}


Youez - 2016 - github.com/yon3zu
LinuXploit