Esempio n. 1
0
/*
 * Move assignment
 */
Carrier& Carrier::operator = ( Carrier&& other) 
{
	std::lock(safeRead, other.safeRead);
	std::lock_guard<std::mutex> self_lock(safeRead, std::adopt_lock);
	std::lock_guard<std::mutex> other_lock(other.safeRead, std::adopt_lock);
  _carrier_type = std::move(other._carrier_type);
	other._carrier_type = '\0';
	_q = std::move(other._q);
	other._q = 0;
	_gen_time = std::move(other._gen_time);
	other._gen_time = 0;
	_x = std::move(other._x); 
	other._x = {0,0};
	_e_field = std::move(other._e_field); 
	other._e_field = {0,0};
	_w_field = std::move(other._w_field);
	other._w_field = {0,0};
	_e_field_mod = std::move(other._e_field_mod);
	other._e_field_mod = 0;
	_sign = std::move(other._sign); 
	other._sign = 0;
	_detector = std::move(other._detector);
	other._detector = NULL;
	_myTemp = std::move(other._myTemp);
	other._myTemp = 0;
	_drift = std::move(other._drift);
	_mu = std::move(other._mu);
	_trapping_time = std::move(other._trapping_time);
	//_electricField = std::move(_electricField);
	//_weightingField = std::move(_weightingField);
	other._trapping_time = 1e300;
	return *this;
}
Esempio n. 2
0
double Point::getAngleTo (Point& other) {
	lock_guard<recursive_mutex> self_lock(value_m);
	lock_guard<recursive_mutex> other_lock(other.value_m);

	double x = other.getValue(0) - getValue(0);
	double y = other.getValue(1) - getValue(1);

	return atan2 (y, x);
}
Esempio n. 3
0
double Point::getDistanceTo (Point& other) {
	lock_guard<recursive_mutex> self_lock(value_m);
	lock_guard<recursive_mutex> other_lock(other.value_m);

	double x = other.getValue(0) - getValue(0);
	double y = other.getValue(1) - getValue(1);

	return sqrt (x * x + y * y);
}
Esempio n. 4
0
Zone& Zone::operator= (Zone& other) {
	if (this == &other)
		return *this;

	lock(value_m, other.value_m);
	lock_guard<recursive_mutex> self_lock(value_m, adopt_lock);
	lock_guard<recursive_mutex> other_lock(other.value_m, adopt_lock);

	// Set this
	color = other.color;

	return *this;
}
Esempio n. 5
0
Point& Point::operator= (Point& other) {
	if (this == &other)
		return *this;

	lock(value_m, other.value_m);
	lock_guard<recursive_mutex> self_lock(value_m, adopt_lock);
	lock_guard<recursive_mutex> other_lock(other.value_m, adopt_lock);

	// Set this
	dimensions = other.dimensions;
	if (axes)
		delete[] axes;
	axes = new double[dimensions]();
	memcpy(axes, other.axes, dimensions * sizeof(double));

	return *this;
}
Esempio n. 6
0
/*
 * Copy assignment
 */
Carrier& Carrier::operator = (const Carrier& other) 
{
	std::lock(safeRead, other.safeRead);
	std::lock_guard<std::mutex> self_lock(safeRead, std::adopt_lock);
	std::lock_guard<std::mutex> other_lock(other.safeRead, std::adopt_lock);
  _carrier_type = other._carrier_type;
	_q = other._q;
	_gen_time = other._gen_time;
	_x = other._x; 
	_e_field = other._e_field; 
	_w_field = other._w_field;
	_e_field_mod = other._e_field_mod;
	_sign = other._sign; 
	_detector = other._detector;
	_myTemp = other._myTemp;
	_drift = other._drift;
	_trapping_time = other._trapping_time;
	//_electricField = other._electricField;
	//_weightingField = other._weightingField;
	return *this;
}
Esempio n. 7
0
File: main.cpp Progetto: CCJY/coliru
 void assign(Other&& other) {
   std::unique_lock<std::mutex> my_lock(mtx, std::defer_lock);
   std::unique_lock<std::mutex> other_lock(other.mtx, std::defer_lock);
   std::lock(my_lock, other_lock);
   data = std::forward<Other>(other).data;
 }