-
Notifications
You must be signed in to change notification settings - Fork 0
F# hw 9 #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
lastSteps/lastSteps/LazyAsync.fs
Outdated
| member v.Get() = | ||
| Monitor.Enter lockObject | ||
| if res.IsNone then | ||
| res <- Some <| supplier() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
И тут в supplier может произойти исключение, которое никто не ловит, монитор остаётся захваченным, дедлок. Есть библиотечная функция lock, которая справляется лучше. Ещё, кстати, имеет смысл прочитать про double-checked locking: https://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html --- такое решение, как у Вас, достаточно хорошо для нашего недокурса по параллельному программированию, но заставляет потоки выстраиваться в очередь на мониторе и убивает весь профит от многопоточности.
lastSteps/Tests/LazyAsync.fs
Outdated
| let res = ans.[0] | ||
| for i in 1..n - 1 do | ||
| ans.[i] |> should equal res | ||
| printf "Ok" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше разбить на несколько тестов, с нормальными названиями
No description provided.