Haskell for Imperative Programmers #28 - Concurrency & Threads

Поделиться
HTML-код
  • Опубликовано: 27 дек 2024

Комментарии • 21

  • @DazzlePirate
    @DazzlePirate 4 года назад +9

    Loving this series!

  • @adamtafesse8971
    @adamtafesse8971 4 года назад +7

    I am only half way through but I just wanted to say video is a great resource! Clear and concise!

  • @nadaxiong
    @nadaxiong 4 года назад +5

    Very clear explanations! Love it!

  • @LeoOno
    @LeoOno 4 года назад +6

    Thanks for these series, they are helping me a lot :) !

  • @moisesbr
    @moisesbr 3 года назад

    Wow, excellent lesson. Most concurrency gotchas in less than half an hour!

  • @yoshieatspizzad913
    @yoshieatspizzad913 3 года назад +3

    for some reason i find the "show tid" at 11:00 incredibly funny

  • @MasthaX
    @MasthaX 4 года назад +1

    This video is very helpful and well explained. They demonstrate possible problems you might encounter pretty well, make sure to use STM though for real life multithreading purposes.

    • @joshuakb2
      @joshuakb2 3 года назад

      What's wrong with using MVars and Channels in "real life" code?

  • @rodrigo_botti
    @rodrigo_botti 4 года назад +1

    Awesome video!
    I'd like to add something: using finally to release the lock on the mutex.
    --
    takeMVar mutex
    finally (putStrLn greeting) (putMVar mutex ())
    --

  • @philipphagenlocher
    @philipphagenlocher  4 года назад +7

    A few remarks: The examples shown are not the prettiest (no exception handling with threads is never a good idea!) and using MVar and Chan for purposes of synchronization is not good practice! There are other datatypes (QSem, QSemN) for this purpose. MVar and Chan are generally not safe and multithreaded code should use Software Transactional Memory which we will look at in another video. System.IO functions are automatically multiplexed when using lightweight threads (spawned by forkIO) but as we have seen: That does not always work! ;)

    • @Nil44419
      @Nil44419 7 месяцев назад +1

      Thanks for the series!

  • @rifaldhiaw
    @rifaldhiaw 4 года назад +3

    Yeeaa... Finally more expert content.
    Thank you and please keep it up

  • @micknamens8659
    @micknamens8659 2 года назад

    Another way to use the mutex would be to start with an empty MVar. A thread would try to store its token in it and would have to wait for the MVar to be empty (again). This approach would also allow to store some information about the locking thread in the lock token. Btw. is there a command to "peek" into an MVar, i.e. for reading w/o removing the value from the MVar?

  • @aegistube
    @aegistube 4 года назад

    Awesome!!! Thank you so much!!!

  • @Silent.
    @Silent. 2 года назад

    Concurrency with Mvar and channels reminds me of concurrency with C

  • @kaksisve4012
    @kaksisve4012 3 года назад +4

    [18:36] I think you can use `replicateM_`.

  • @lpi3
    @lpi3 3 года назад +1

    I would use replicateM in place of mapM

  • @maxreuv
    @maxreuv 4 года назад +1

    Very good

  • @shutterrecoil
    @shutterrecoil 2 года назад

    putStrLn mutex needs a bracket.