コード例 #1
0
ファイル: Carrier.cpp プロジェクト: UrbSen/TRACS
/*
 * 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;
}
コード例 #2
0
ファイル: point.cpp プロジェクト: Ynigvi/stibbons
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);
}
コード例 #3
0
ファイル: point.cpp プロジェクト: Ynigvi/stibbons
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);
}
コード例 #4
0
ファイル: zone.cpp プロジェクト: Ynigvi/stibbons
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;
}
コード例 #5
0
ファイル: point.cpp プロジェクト: Ynigvi/stibbons
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;
}
コード例 #6
0
ファイル: Carrier.cpp プロジェクト: UrbSen/TRACS
/*
 * 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;
}
コード例 #7
0
ファイル: http_address.c プロジェクト: techpub/archive-code
int
    http_address_thread_close (
    http_address_table_t * table,       //  Not documented
    http_access_context_t * context     //  Not documented
)
{
ipr_looseref_t
    *looseref;
http_address_t
    *self;
smt_thread_t
    *thread;
    int
        rc = 0;                         //  Not documented

#if (defined (BASE_ANIMATE)  ||  defined (BASE_ANIMATE_HTTP_ADDRESS)  ||  defined (BASE_ANIMATE_HTTP_ADDRESS_THREAD_CLOSE))
    if (http_address_animating)
        icl_console_print ("<http_address_thread_close_start"
#if (defined (BASE_THREADSAFE))
" thread=\"%pp\""
#endif
" table=\"%pp\""
" context=\"%pp\""
"/>"
#if (defined (BASE_THREADSAFE))
, apr_os_thread_current ()
#endif
, table, context);
#endif

#if (defined (BASE_TRACE)   || defined (BASE_TRACE_HTTP_ADDRESS)   || defined (BASE_TRACE_HTTP_ADDRESS_THREAD_CLOSE))
    icl_trace_record (NULL, http_address_dump, 4);
#endif

#if (defined (BASE_STATS)  ||  defined (BASE_STATS_HTTP_ADDRESS)  ||  defined (BASE_STATS_HTTP_ADDRESS_THREAD_CLOSE))
    icl_stats_inc ("http_address_thread_close", &s_http_address_thread_close_stats);
#endif

//
assert (table);
assert (context);
assert (context->address);
assert (context->thread);

self = http_address_table_search (table, context->address);
assert (self);
self_lock (self);

//  Find looseref entry for context->thread
looseref = ipr_looseref_list_first (self->thread_list);
while (looseref
&& (smt_thread_t *) looseref->object != context->thread)
    looseref = ipr_looseref_list_next (&looseref);

if (looseref) {
    //  Now kill the thread and get back our quota
    thread = (smt_thread_t *) looseref->object;
    ipr_looseref_destroy (&looseref);
    assert (thread);
    smt_thread_shut_down (thread);
    smt_thread_unlink (&thread);
    self->thread_quota++;
}
self_unlock (self);
#if (defined (BASE_TRACE)   || defined (BASE_TRACE_HTTP_ADDRESS)   || defined (BASE_TRACE_HTTP_ADDRESS_THREAD_CLOSE))
    icl_trace_record (NULL, http_address_dump, 0x10000 + 4);
#endif

#if (defined (BASE_ANIMATE)   || defined (BASE_ANIMATE_HTTP_ADDRESS)   || defined (BASE_ANIMATE_HTTP_ADDRESS_THREAD_CLOSE))
    if (http_address_animating)
        icl_console_print ("<http_address_thread_close_finish"
#if (defined (BASE_THREADSAFE))
" thread=\"%pp\""
#endif
" table=\"%pp\""
" context=\"%pp\""
" rc=\"%i\""
"/>"
#if (defined (BASE_THREADSAFE))
, apr_os_thread_current ()
#endif
, table, context, rc);
#endif


    return (rc);
}
コード例 #8
0
ファイル: http_address.c プロジェクト: techpub/archive-code
int
    http_address_thread_open (
    http_address_table_t * table,       //  Not documented
    http_access_context_t * context     //  Not documented
)
{
http_address_t
    *self;
smt_thread_t
    *thread;
    int
        rc = 0;                         //  Not documented

#if (defined (BASE_ANIMATE)  ||  defined (BASE_ANIMATE_HTTP_ADDRESS)  ||  defined (BASE_ANIMATE_HTTP_ADDRESS_THREAD_OPEN))
    if (http_address_animating)
        icl_console_print ("<http_address_thread_open_start"
#if (defined (BASE_THREADSAFE))
" thread=\"%pp\""
#endif
" table=\"%pp\""
" context=\"%pp\""
"/>"
#if (defined (BASE_THREADSAFE))
, apr_os_thread_current ()
#endif
, table, context);
#endif

#if (defined (BASE_TRACE)   || defined (BASE_TRACE_HTTP_ADDRESS)   || defined (BASE_TRACE_HTTP_ADDRESS_THREAD_OPEN))
    icl_trace_record (NULL, http_address_dump, 3);
#endif

#if (defined (BASE_STATS)  ||  defined (BASE_STATS_HTTP_ADDRESS)  ||  defined (BASE_STATS_HTTP_ADDRESS_THREAD_OPEN))
    icl_stats_inc ("http_address_thread_open", &s_http_address_thread_open_stats);
#endif

//
assert (table);
assert (context);
assert (context->address);
assert (context->thread);

self = http_address_table_search (table, context->address);
if (!self) {
    self = http_address_new (table, context->address);
    //  This can return null if two threads create the same address at
    //  the same time... so let's go find the actual address object
    if (!self) {
        self = http_address_table_search (table, context->address);
        assert (self);
    }
}
assert (self);

self_lock (self);
ipr_looseref_queue (self->thread_list, smt_thread_link (context->thread));
//  Cull oldest thread if quota is non-zero but would become zero
//  I.e. if it's exactly one... a quota of zero means "unlimited".
if ( self->thread_quota
&& --self->thread_quota == 0) {
    //  Find oldest looseref entry
    thread = (smt_thread_t *) ipr_looseref_pop (self->thread_list);
    assert (thread);
    smt_thread_shut_down (thread);
    smt_thread_unlink (&thread);
    self->thread_quota++;
}
self_unlock (self);
#if (defined (BASE_TRACE)   || defined (BASE_TRACE_HTTP_ADDRESS)   || defined (BASE_TRACE_HTTP_ADDRESS_THREAD_OPEN))
    icl_trace_record (NULL, http_address_dump, 0x10000 + 3);
#endif

#if (defined (BASE_ANIMATE)   || defined (BASE_ANIMATE_HTTP_ADDRESS)   || defined (BASE_ANIMATE_HTTP_ADDRESS_THREAD_OPEN))
    if (http_address_animating)
        icl_console_print ("<http_address_thread_open_finish"
#if (defined (BASE_THREADSAFE))
" thread=\"%pp\""
#endif
" table=\"%pp\""
" context=\"%pp\""
" rc=\"%i\""
"/>"
#if (defined (BASE_THREADSAFE))
, apr_os_thread_current ()
#endif
, table, context, rc);
#endif


    return (rc);
}