Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4atomic.hh 파일 참조

Definition of the G4atomic class. 더 자세히 ...

이 파일의 소스 코드 페이지로 가기


template<typename _Tp >
using G4atomic = _Tp

상세한 설명

Definition of the G4atomic class.

G4atomic.hh 파일에서 정의되었습니다.

타입정의 문서화

template<typename _Tp >
using G4atomic = _Tp

This is an friendly implementation of the STL atomic class. This class has the same interface as the STL atomic but can be used in an extremely similar fashion to plain old data (POD) types. In other words, the copy constructor and assignment operators are defined, and a load() does not need to be called to get the POD value.

IMPORTANT: Care must be taken when using this class as a RHS term. The best use case scenario for this class is as a LHS term that is only used as a RHS term outside of the multithreaded operations on it.

FOR EXAMPLE: Proper use: Goal: sum energy deposited in run Impl: Is a member variable of derived G4VUserActionInitialization (of which there will always be just one instance). Accumulate thread-local energy deposit into EventAction, add to ActionInit at end of event, print sum on master EndOfRunAction Why: the sum is only a LHS term Improper use: Goal: compute error during event processing Impl: sum += x; sum_sq += x*x; counts++; error = sqrt(sum_sq/(sum*sum) - 1/counts; (where sum, sum_sq, counts are G4atomics) Why: This will work but error can/will be wrong when sum, sum_sq, and counts are updated by another thread while error is being calculated, i.e. they are used as RHS terms

G4atomic.hh 파일의 265 번째 라인에서 정의되었습니다.