http://msdn.microsoft.com/en-us/magazine/cc163744.aspx
For a lock to provide mutual exclusion for a region of memory, no writes to that memory can occur without entering the same lock. In a properly designed program, associated with every lock is a region of memory for which it provides mutual exclusion. Unfortunately, there is no obvious artifact of the code that makes this association clear, and yet this information is absolutely critical for anyone reasoning about the multithreaded behavior of the program.
what would be the ideal syntax? what comes to mind is
For a lock to provide mutual exclusion for a region of memory, no writes to that memory can occur without entering the same lock. In a properly designed program, associated with every lock is a region of memory for which it provides mutual exclusion. Unfortunately, there is no obvious artifact of the code that makes this association clear, and yet this information is absolutely critical for anyone reasoning about the multithreaded behavior of the program.
what would be the ideal syntax? what comes to mind is
object myLock = new object(); [Protected(myLock)] MyState myState;x-posted
(no subject)
Date: 2008-07-25 12:30 am (UTC)name, height and weight, которым присваиваются значения, это свойства какого объекта? вот у этого объекта и нарушается инвариант, его и надо лочить. или подробнее надо?
(no subject)
Date: 2008-07-25 01:21 am (UTC)Так чо, где тут ресурс-то?
(no subject)
Date: 2008-07-31 07:29 pm (UTC)в рамках же описанного тобой замечательного дизайна ближайший объект, накоторый мапится этот disjoint set, это объект №4. и да, если его лочить, concurrency будет хуёвая, и кто в этом виноват?
дальше тут можно очень много слов сказать о том, как сделать лучше, но это всё будет в основном про оо дизайн, а не про мультитредность. в хорошем оо дизайне редко возникают вопросы, куда смапить инвариант; само наличие инварианта является фактором, влияющим на дизайн.
безусловно, бывают исключения, и я даже готов про них поговорить, но только в оо рамках. и я бы таки порекомендовал сначала статью прочитать, ибо там на многие простые вопросы очень хорошо отвечено, а то будет как с соловьёвым.