403Webshell
Server IP : 66.29.132.122  /  Your IP : 18.225.149.42
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/counter.hpp
#ifndef _COUNTER_HPP_
#define _COUNTER_HPP_

#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
#include <boost/thread/thread_time.hpp>

struct Counter;
typedef boost::shared_ptr<Counter> CounterPtr;

/**
 * A synchronization mechanism with counter-like properties.
 *
 * To avoid memory corruption when unit tests fail, one should
 * never store Counter objects on the stack. Instead, one should
 * create them on the heap and use CounterPtr smart pointers.
 */
struct Counter {
	struct timeout_expired { };
	
	unsigned int value;
	boost::mutex mutex;
	boost::condition_variable cond;
	
	static CounterPtr create_ptr() {
		return CounterPtr(new Counter());
	}
	
	Counter() {
		value = 0;
	}
	
	/**
	 * Wait until other threads have increment this counter to at least wanted_value.
	 * If this doesn't happen within <tt>timeout</tt> miliseconds, then a timeout_expired
	 * exception will be thrown.
	 */
	void wait_until(unsigned int wanted_value, unsigned int timeout = 1000) {
		boost::unique_lock<boost::mutex> l(mutex);
		while (value < wanted_value) {
			if (!cond.timed_wait(l, boost::get_system_time() + boost::posix_time::milliseconds(timeout))) {
				throw timeout_expired();
			}
		}
	}
	
	/** Increment the counter by one. */
	void increment() {
		boost::unique_lock<boost::mutex> l(mutex);
		value++;
		cond.notify_all();
	}
};

#endif /* _COUNTER_HPP_ */

Youez - 2016 - github.com/yon3zu
LinuXploit