나는 빠른 Google 검색을 수행했으며 Ruby의 원 자성에 대해 작성된 거의 모든 것이 작업을 둘러싼 뮤텍스 배치를 제안합니다. 그러나이 방법은 신호가 동기화 된 코드를 방해 할 수 있으므로 원 자성의 일반적인 정의를 충족시키지 못한다고 생각합니다. 예를 들어 (Ruby Best Practices에서 가져온) :Ruby에서 원 자성으로 보장/문서화 된 연산/메소드가 있습니까?
lock = Mutex.new
# XXX this is an example of what NOT to do inside a signal handler:
trap(:USR1) do
lock.synchronize do
# if a second SIGUSR1 arrives here, this block of code
# will fire again. Attempting Mutex#synchronize twice
# the same thread leads to a deadlock error
end
end
그 자성이 높은 수준의 언어 덜 중요하다 이해하지만, 연구를 위해 나는 GIL와 구현이 문제에 정식 답변을 얻을 싶습니다 (예 : MRI 2.0.0) 없이JRuby 1.7.4 및 Rubinius 1.2.4
루비 엔진과 버전은 무엇입니까? –
Ruby의 원자 적 연산 : http://moonbase.rydia.net/mental/blog/programming/atomic-operations-in-ruby.html – ChrisInEdmonton
MRI는 [GIL] (https://en.wikipedia.org/wiki/Global_Interpreter_Lock) 때문에 JRuby 및 Rubinius와 매우 다릅니다. –