How to use threads in C++11 (multitasking, mutual exclusion, etc.)

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ม.ค. 2016
  • In this tool-assisted education video I explain the tools that C++11 introduced for creating multi-threaded programs. We will study each concept individually from #threads to condition variables and from futures to promises.
    ENGLISH-LANGUAGE CLOSED CAPTIONS ARE AVAILABLE.
    The source code and other materials can be DOWNLOADed here: bisqwit.iki.fi/jutut/kuvat/pr...
    You can contribute subtitle translations at: th-cam.com/users/timedtext_vid...
    If you want to help me with money, I have a Patreon page at: / bisqwit
    Music used in the video, in order of appearance:
    - Wizardry V :: Artifacts (Kentarou Haneda)
    - Star Ocean :: Calm Time (Motoi Sakuraba)
    - Wonder Project J :: House (Akihito Mori)
    All music was converted into MIDI and played using OPL3 simulation with homebrew software. The exact process is described here: • SNES music through OPL...
    Footage music (also played through homebrew software):
    - Cave Story :: Geothermal
    Cameras used: Canon EOS 1200D, Canon PowerShot SX110IS
    Lens: Tokina AT-X PRO 11-16mm F2.8 DX
    Programming footage in: DOSBox
    Resampling with: ffmpeg
    Video editing in: kdenlive
    Audio editing in: audacity & kdenlive
    Muxing in: mkvmerge
    Production dates: 2015-12-03 through 2016-01-22
    Desktop computer is: Raspberry Pi
    Secret code: OwjQkUo9Bgk
    Compilers used: GCC 5.3.1
    Robot is: Nao V4
    If anything in the video requires clarification, please write a comment. I try to reply to every unique comment that contains a question addressed to me. Please make sure your privacy settings (possibly found as far as in Google+) will not prevent me from actually replying.
    The editor used in the video, with Mario and all, is a 16-bit homebrew editor that only runs in 16-bit DOS. You can download it at the download page, but note that it is only designed for video making. It’s not meant for actual use, but it does work and is largely modelled after Joe.
    Joseph Allen’s “Joe” editor makes an appearance at 21:11. You can find Joe at: joe-editor.sourceforge.net/ . It is my primary editing environment, both in Linux and in Cygwin. I am not using any other IDE.
    Linux is used under DOSBox (for purpose of video production only) by using a modified version of DOSBox that provides forkpty() functions as DOS interrupts, and a homebrew terminal program running in DOS, that supports xterm-256color escapes. The terminal program is useless without the patched version of DOSBox (and furthermore this patch will only work in Linux). Nonetheless you can find both on the download page, linked above.
    Reference material used and highly recommended:
    en.cppreference.com/w/cpp/thre...
    en.cppreference.com/w/cpp/thre...
    en.cppreference.com/w/cpp/thre...
    en.cppreference.com/w/cpp/thre...
    en.cppreference.com/w/cpp/thre...
    en.cppreference.com/w/cpp/thre...
    en.cppreference.com/w/cpp/thre...
    en.cppreference.com/w/cpp/stri...
    About author: Joel Yliluoma is an author who publishes videos in TH-cam under the name “Bisqwit”, ranging diverse topics from programming to gaming and from cats to religion. He has been programming since 1992, and for most years since then, it has been his primary, sometimes only hobby. Though most of his professional life has been spent developing business web applications, he prefers working with low level code targeting older systems. In 2014―2015 he was also a coach driver working for Savonlinja in Finland. He is also known for founding TASVideos.org, a website and community centered around making “tool-assisted” speedruns of classic video games. Outside Internet, he is known for teaching Israeli folk dance in Finland.
    Twitter: / realbisqwit
    Patreon: / bisqwit (alternatives at iki.fi/bisqwit/donate.html)
    Twitch: / realbisqwit
    Homepage: iki.fi/bisqwit/
    The source code and other materials can be DOWNLOADed here: bisqwit.iki.fi/jutut/kuvat/pr...
    You can contribute subtitle translations at: th-cam.com/users/timedtext_vid...
    If you want to help me with money, I have a Patreon page at: / bisqwit
    Note to self: Possible topics for a hypothetical second episode:
    - Thread-local variables
    - Memory order declarations
    - What the standard says about memory interactions between threads
    - What the standard guarantees about when variable changes are committed into RAM
    - Clustering
    - CPU affinity
    #Bisqwit #ThreadProgramming #Tutorial #Parallelism #Programming

ความคิดเห็น • 277

  • @Bisqwit
    @Bisqwit  5 ปีที่แล้ว +30

    Information evacuated from annotations that TH-cam dropped support for in 2019-01-15:
    12:35 “std::async is more convenient to use than std::thread, but std::thread has lower overhead. Use std::async when you are running something "asynchronously" on the background and you need the results only later at some particular point in the program. Use std::thread when you are doing threads in bulk for parallel processing.”
    13:13 “You would use std::promise when you want to send a value into std::future, while still continuing to execute the thread/asynchronous function.”
    13.39 “Clarification: The std::promise is not the only way to pass exceptions. E.g. if the function, that is called with std::async, throws an exception and it is not caught, it will be transmitted through the std::future associated with the std::async call. The same goes with std::packaged_task.”
    14:00 “In my opinion, the reason why you would use std::future at all, is that it is more convenient than some alternatives composed from lower-level constructs.”
    21:33 “Note: Using sched_yield() or std::this_thread::yield() would be a mistake. It is ineffective solution.”

  • @yayafitini
    @yayafitini 8 ปีที่แล้ว +139

    it's not like i understand what he's doing , i subscribed cause i wish i could do this. fascinating

    • @Hrithmus
      @Hrithmus 7 ปีที่แล้ว +2

      Hahahaha same here man

    • @TheClockwerkman
      @TheClockwerkman 7 ปีที่แล้ว +3

      Go read the about threads

  • @RoamingAdhocrat
    @RoamingAdhocrat 5 ปีที่แล้ว +33

    Forget threads. `std::cout

    • @michaelscofield1970
      @michaelscofield1970 4 ปีที่แล้ว +6

      That '
      ' info blew my mind. I am forever in debt to Bisqwit

  • @CP200S
    @CP200S 8 ปีที่แล้ว +9

    Bisqwit, the world needs more people like you!

  • @whatamievendoing
    @whatamievendoing 8 ปีที่แล้ว +1

    You've become one of my favorite broadcasters on TH-cam! Your videos are a lot of fun to watch.

  • @rebecca6683
    @rebecca6683 8 ปีที่แล้ว +12

    your voice is so soothing i love it, i just listen to your voice while i'm at work

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว +3

      +a Thank you!

    • @mighty2146
      @mighty2146 3 ปีที่แล้ว +1

      Also the bgm its just too good and nostalgic + his sound is somewhat robotic it makes it even better

    • @kenkelvin4023
      @kenkelvin4023 2 ปีที่แล้ว

      >She

    • @Bisqwit
      @Bisqwit  2 ปีที่แล้ว +1

      ?

  • @Bisqwit
    @Bisqwit  8 ปีที่แล้ว +23

    +Mikko Finell It's a matter of whether you prefer thinking much to type little, or thinking little to type lots, to achieve the same outcome. As the saying goes: work smarter, not harder.
    (Also, I can't reply to your comment directly. Please check your Google+ privacy settings.)

    • @treldar
      @treldar 7 ปีที่แล้ว

      Which do you prefer in a context of your choosing? I usually find myself thinking lots and typing little, though i've questioned my process due to possible recurring inefficiencies. Unfortunately, i fear a lack of perspective to realize if my process is ripe for change, hence my seemingly shallow question.

  • @lfa8903
    @lfa8903 7 ปีที่แล้ว +1

    You talk very clearly, going straight to the point and not waisting time. I like your tutorial. Thank you!

  • @jacobsullivan8512
    @jacobsullivan8512 8 ปีที่แล้ว +2

    Thanks for the video! I always enjoy hearing about what you have been working on.

  • @tamburine
    @tamburine 8 ปีที่แล้ว +1

    Thanks! Introduction to futures is great. I was struggling to understand it since I read about them in "C++ concurrency in action", and only now I feel I get something.

  • @haxpor
    @haxpor 5 ปีที่แล้ว

    Only 5 minutes mark, it already packed several of new knowledge for me. Thanks!

  • @CalBart42
    @CalBart42 7 ปีที่แล้ว

    You Sir are a true gentleman and a pleasure to listen too and learn from ... thanks for sharing your knowledge

  • @velocityra
    @velocityra 8 ปีที่แล้ว +15

    WOOHOO new Bisquit video!

  • @jojodi
    @jojodi 8 ปีที่แล้ว +1

    Great video :) I hope over time we can have more tools in the standard library. Standardized threading is wonderful!

  • @SuperNolane
    @SuperNolane 8 ปีที่แล้ว +2

    I love your manner of explanation. Perfect work.

    • @meJevin
      @meJevin 7 ปีที่แล้ว

      ага

  • @anonimenkolbas1305
    @anonimenkolbas1305 8 ปีที่แล้ว +1

    Great video as always. Thank you for taking the time to teach us! :)

  • @wesmatron
    @wesmatron 8 ปีที่แล้ว +6

    You are a bloody legend.

  • @MarkIn4D
    @MarkIn4D 8 ปีที่แล้ว +8

    Oh, and I was just trying to be educated about this topic a few days ago, how nice of you to share a video about it.
    Excellent editing as usual. :)

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว +6

      +Márk Morshu Thank you!

    • @FirstLast-fx3mf
      @FirstLast-fx3mf 7 ปีที่แล้ว

      Bisqwit So std is function? I thought it was a sexual transmitted disease

    • @Bisqwit
      @Bisqwit  7 ปีที่แล้ว +3

      std in the context of C++ is an abbreviation for standard. It is used as the identifier for standard namespace functions.
      I realize this may be a totally revolutionary idea that you have never thought before, but abbreviations and acronyms can actually have multiple meanings! For example, P.S. may mean Post Scriptum, but it may also mean Photoshop, Playstation, Psalms, or about three hundred other things. There are a number of free websites cataloging well-known meanings of acronyms and abbreviations. For example: www.acronymfinder.com/STD.html Hope this helps!

    • @FirstLast-fx3mf
      @FirstLast-fx3mf 7 ปีที่แล้ว

      +Bisqwit I'm just joking I know what std means in C++ 14. Hey I got question like do have tutorials that involve making emulators in C# in visual studios because I'm more fimiliar with coding in C# and I really want to make my first emulator but I don't know how to start because they really isn't any tutorials on how to make emulators on C# and I'm really fluent in that programming language. I only seen emulators being done in C++ or in java but never in C# and I know it can be done in C# because Visual Studios has intergated OpenGL ES 3.0 support for applications your making. Like I already made my first application which used Threads, while loops, if and else statements. The threads are really easy for me to code in C# there's some differences between C# and C++ 14 but it's the same functions it does because I remember when I ran the threads for the first time I had to modify it because it was you using the cpu 100% so I had to make the threads sleep so it can run perfectly only using 1% of the cpu. Same concept but it just structure differently.

    • @Bisqwit
      @Bisqwit  7 ปีที่แล้ว +4

      I know you were joking. It is also my type of humor to respond to such joke in an all serious and excessively smothering style, in case that wasn't obvious.
      As for C# and Visual Studio, I'm not fond of vendor-lock-in and products of that vendor in general -- or in fact, products in general, so no. I like teaching people ideas and technologies, not products.
      "because it was you using the cpu 100%" I think I'm having trouble parsing your message. You seemed to be talking about C# and about your adventures with thread programming, but suddenly there was a word "you" out of blue. What are you talking about?

  • @josemaria2094
    @josemaria2094 5 ปีที่แล้ว +1

    You are an example for me, totaly awesome!

  • @graphoverflow
    @graphoverflow 7 ปีที่แล้ว

    His voice and the music is so calm and I could just watch it because it's soo soothing :)

  • @theseriousaccount
    @theseriousaccount 8 ปีที่แล้ว +1

    This video is great. I'm subbed
    , looking forward to more

  • @mikaelmoizt
    @mikaelmoizt 8 ปีที่แล้ว +1

    Nice to see a new video! Although I don't understand much of it, I kind of get the idea of it. The elgegancy of high level programming always fascinates me :)

  • @godDIEmanLIVE
    @godDIEmanLIVE 4 ปีที่แล้ว +1

    Just implemented my first thread yesterday and cheered triumphantly. After watching this I feel like a damn peasant :D

    • @FlavourlessLife
      @FlavourlessLife 4 ปีที่แล้ว +1

      Bisqwit is the real deal. You know the child's toy where there are different shaped blocks with matching shaped holes?... After watching Bisqwit I feel like my programming abilities are equivalent to a baby trying to repeatedly smash the triangle through the square shaped hole. Then I give up, throw it on the floor and look for something else to play with.

  • @lauretivan6231
    @lauretivan6231 7 ปีที่แล้ว

    Found your channel like that ! awesome what you do and learn, programmer too, your blog is awesome too !!!

  • @KamiKagutsuchi
    @KamiKagutsuchi 8 ปีที่แล้ว

    The music, narration and style of the entire thing reminds me so much of the Hitchicker's Guide to the Galaxy tv show!

  • @kikos055
    @kikos055 7 ปีที่แล้ว

    This is just amazing Bisqwit ! Keep up please ;)

  • @InnocentEX
    @InnocentEX 8 ปีที่แล้ว

    Great Video! Your explanations are excellent.

  • @MindLessWiz
    @MindLessWiz 8 ปีที่แล้ว +1

    Brilliant!! Thank you so much!

  • @NonTwinBrothers
    @NonTwinBrothers 2 ปีที่แล้ว

    (Thank you for putting subtitles in all your videos!)

  • @Humble_Electronic_Musician
    @Humble_Electronic_Musician 6 หลายเดือนก่อน

    Clear, concise and very good explanation 🙏🏻!

  • @vittorioromeo1
    @vittorioromeo1 8 ปีที่แล้ว +11

    Excellent tutorial! Shared it with my followers. I have been guilty of using "busy loops" before getting acquainted with `std::condition_variable`...

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว +10

      +Vittorio Romeo Thank you! Also congratulations on your 3000th!

  • @Junior7setti
    @Junior7setti 8 ปีที่แล้ว +2

    LOL! I am still laughing cuz of that blue screen of death.
    Unfortunately I had to learn this topic in the hard way.
    Nice tutorial! I wish I had it when I first started working with threads.
    About the game loop, I spent months trying to figure out that LOL!

  • @goldchalice
    @goldchalice 8 ปีที่แล้ว

    Promises and futures are very popular concepts in apps found on the web. Learning to use promises really made asynchronous programming eloquent.

  • @version191
    @version191 8 ปีที่แล้ว

    Heart of maelstrom soundtrack is amazing. Love your videos, cheers

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      +version191 It is, yeah. I haven't listened to the entire soundtrack, as I picked this song (Wizardry V, Artifacts) by random from a selection of all SNES games, but the couple I did listen from this game were quite nice.

  • @misterj9817
    @misterj9817 7 ปีที่แล้ว

    Thank You so much, Great work. I really appreciate it.

  • @rafaelmoura8688
    @rafaelmoura8688 8 ปีที่แล้ว

    uhuul, nice Bisqwit.

  • @bibasniba1832
    @bibasniba1832 4 ปีที่แล้ว

    Thanks Bisqwit!

  • @halemm
    @halemm 8 ปีที่แล้ว +1

    wow excellent video, as always!

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว +2

      +Hal Emmerich Thank you very much!

  • @revoiceful
    @revoiceful 6 ปีที่แล้ว

    I liked the concept of diving deep into an example and then coming back to an easy one again. This really refreshed the concept and made the following example a lot easier to understand. I even found the pending error on the Producer/Consumer example before you explained it (I am no C/C++ programmer, just scripting languages)

    • @Bisqwit
      @Bisqwit  6 ปีที่แล้ว

      Thank you for your feedback!

  • @whynot-vq2ly
    @whynot-vq2ly 4 ปีที่แล้ว

    the only problem I have when watching your videos is the amont of informations there is
    it's really great and well done. no side talks no long and boring explantions only pure code juice. thanks

    • @Bisqwit
      @Bisqwit  4 ปีที่แล้ว

      That doesn’t seem like a problem! Thanks for writing.

    • @whynot-vq2ly
      @whynot-vq2ly 4 ปีที่แล้ว

      @@Bisqwit thanks for replying :]

  • @paulkerrigan9857
    @paulkerrigan9857 8 ปีที่แล้ว +18

    You are a smart man, thanks for these tutorials. I learned with C# and use PHP for my day job.
    I worry that those are far too high-level to learn about how the computer operates, so I'm learning C++ in my spare time, with Direct3D 11. I'm still a beginner, because I feel embarrassed each time I read my old code.
    I don't want abstractions to hinder my understanding.
    Can you tell us how you learned to code? I'm guessing you experiment a lot - you write your own editor for DOS and demonstrate familiarity with a great deal of subjects.
    Thanks for your videos. Very interesting.

    • @danilo2735
      @danilo2735 4 ปีที่แล้ว +1

      update, did you learn c++?

    • @jockey7779
      @jockey7779 3 ปีที่แล้ว +1

      Hope you can learn C++ it really is a good language

    • @tototrapsilo
      @tototrapsilo ปีที่แล้ว

      How it's now?

  • @luisponce3580
    @luisponce3580 4 ปีที่แล้ว

    Liked the video because of the video's description

  • @monolyth421
    @monolyth421 7 ปีที่แล้ว +13

    ♪(Nice music continues)♪

  • @RahulJain-wr6kx
    @RahulJain-wr6kx 3 ปีที่แล้ว

    Excellent Tutorial

  • @pleinair6318
    @pleinair6318 8 ปีที่แล้ว

    amazing tutorial!

  • @cr9pr3
    @cr9pr3 8 ปีที่แล้ว

    excellent video!

  • @JovenAlbarida
    @JovenAlbarida 7 ปีที่แล้ว +1

    like all your videos :) thanks

  • @ancientapparition1638
    @ancientapparition1638 7 ปีที่แล้ว

    Thanks much my friend

  • @Fr3akyPL
    @Fr3akyPL 8 ปีที่แล้ว

    You are crazy! Great video!

  • @yashwanthcb
    @yashwanthcb 7 ปีที่แล้ว

    you are so obedient

  • @0XAN
    @0XAN 6 ปีที่แล้ว

    you are the best!

  • @Luftbubblan
    @Luftbubblan 7 ปีที่แล้ว

    Nice video.
    It feels pretty hard for me to follow doe so i have to watch it multiple times :P

  • @JovenAlbarida
    @JovenAlbarida 7 ปีที่แล้ว +5

    what kind C++ editor you used? I like the Mario characters running on the top status bar :D

    • @BucifalulR
      @BucifalulR 7 ปีที่แล้ว +5

      @Joven Albarida: I was wondering the same and it actually seems our question's been answered in the description :). I'll copy-paste, but you can also find this in the video description:
      "The editor used in the video, with Mario and all, is a 16-bit homebrew editor that only runs in 16-bit DOS. You can download it at the download page, but note that it is only designed for video making. It’s not meant for actual use, but it does work and is largely modelled after Joe.
      Joseph Allen’s “Joe” editor makes an appearance at 21:11. You can find Joe at: joe-editor.sourceforge.net/ . It is my primary editing environment, both in Linux and in Cygwin. I am not using any other IDE."

  • @redchards
    @redchards 8 ปีที่แล้ว

    First of all, very pleasant and informative video. But also, your english speaking really improved, especially the speech flow !
    Oh, and one question, I'm not aware of you having any blog or things like that, do you plan to make some written articles along with your programming videos ? It could allow you to speak about subjecst you wouldn't have time to cover in one video, without all the work video recording and editing.
    Anyway, always a pleasure to watch your videos !

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      +Loic Urien Thank you for the very nice feedback. As for speech, I think it got a little better in the second half, as I had been listening kdenlive play my speech at slow speed (because it's extremely laggy with 60fps 2160p video) and I was beginning to notice some patterns in my inflection. No, I don't currently have any blog the sort you are described. I may at some point add some potentially missing information on the download page, that currently is just a list of downloadable files.

  • @monolyth421
    @monolyth421 7 ปีที่แล้ว

    Hi Bisqwit, I am confused about what is happening on this line:
    return Out((r

    • @Bisqwit
      @Bisqwit  7 ปีที่แล้ว +8

      Where ever it reads std::forward(x), you can just read, x.
      std::forward just ensures that the type is perfectly forwarded without any conversions.
      So basically, the function definition, that this line is part of, does this:
      Out(r, a, things...)
      becomes
      Out( (r

  • @terrencecoccoli524
    @terrencecoccoli524 7 ปีที่แล้ว

    Your voice reminds me of that classic film The Seventh Seal.

  • @darktrece
    @darktrece 7 ปีที่แล้ว

    what online courses for Cpp do you recommend? thanks for sharing

  • @pavelp80
    @pavelp80 6 ปีที่แล้ว

    Good work. You deserve a biscuit :-) or box of them, well a donation ...

  • @ronaegis
    @ronaegis 8 ปีที่แล้ว

    Great video! I would suggest declaring the 'end' variable as volatile at 19:04 since the tests on it could be optimized out by some compilers. :)

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว +1

      +ronaegis You may have misunderstood something. Declaring a variable volatile never leads into optimizations. Rather, it is very much the opposite. It means the compiler can _never_ optimize and combine two reads into one, or assume that a variable that was just written will have the same value when read again. The only reason why people think it's good for use with threads is because it forces the compiler to always access the variable from memory, ensuring that it will never use a cached value from the very fast CPU registers, because it might possibly be stale. It most definitely will not lead into optimizations.

    • @thetrickster42
      @thetrickster42 8 ปีที่แล้ว

      +Bisqwit I think he means that the optimiser might 'optimise' away the tests without volatile in the variable's definition.

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      +Conor Manning Oh. I see. That makes sense. I am not really sure, but I _think_ the compiler is not really permitted to do that either. What _is_ apparently permitted is that the writes into memory are not synchronized between CPU cores, and `volatile` is _not_ designed to help that in any manner. Quoting stackoverflow.com/questions/4557979/when-to-use-volatile-with-multi-threading:
      The C++11 Standard now _does_ acknowledge multithreading directly in the memory model and the language, and it provides library facilities to deal with it in a platform-independent way. However the semantics of `volatile` still have not changed. `volatile` is still not a synchronization mechanism. _Bjarne Stroustrup_ says as much in TCPPPL4E:
      "Do not use `volatile` except in low-level code that deals directly with hardware.
      Do not assume `volatile` has special meaning in the memory model. It does not. It is not -- as in some later languages -- a synchronization mechanism. To get synchronization, use `atomic`, a`mutex`, or a `condition_variable`."

    • @thetrickster42
      @thetrickster42 8 ปีที่แล้ว +1

      Yeah, this thread (stackoverflow.com/questions/24126091/is-it-a-bug-for-g-and-clang-optimization) cleared it up in my mind. The asker has a bug in his code which I can reproduce on my machine.
      The top answer to that question is helpful:
      "No. The C and C++ memory models do not permit cross-thread interactions for non-atomic variables, or when not protected by a mutex/lock. This is a data race and in violation of the abstract machine, so the optimizer is perfectly within its rights to launch Nethack.
      The optimizer is written to assume, as it is explicitly permitted to do so by Standard, that external sources (including other threads) cannot magically mutate your program's state without explicit control by the user."
      So if we want to use optimising compilers, we have to be careful to eliminate data races, even ones we don't care about. That said, atomic can be used to eliminate bugs like this, still no need for volatile.

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      +Conor Manning Thank you! Not as entertaining an explanation as the traditional references to nasal demons, but very useful nonetheless.

  • @jarrad2000
    @jarrad2000 8 ปีที่แล้ว +1

    Thank you, very nice tutorial. I'm a new subscriber and even though I think your channel is a little weird it somehow has a distinct charm. I don't mean this offensive (I'm German so I have an accent in English as well) but at first I thought your voice was some kind of speech synthesis ;) Your english is very good, it's just about the speed / pitch... I don't know... it just sounds really similar to early speech synthesis to me.

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      +jarrad2000 Sorry about that. That is just me trying to tackle the triathlon tongue twisters in the English language. That, and the fact that everything I say audio-only in this video is 100% scripted, because if I try to go off script, I totally lose my train of thought and fail to put things in the concise format you are familiar with in my videos. (You can see an example of me going off script at 0:54-1:15. Compare with subtitles. Or compare with video th-cam.com/video/h37xb8YkMJ4/w-d-xo.html which is me going _entirely_ without a script.) There's very little that I can do about these, except to shut up and not talk, or to keep doing it and hope that within the passage of years some improvement is made.

    • @jarrad2000
      @jarrad2000 8 ปีที่แล้ว

      Bisqwit No, I am sorry. I did not mean this as critique or offense. Your english is good and can be well understood. I even like the accent but like I said I just think it sounds similar to early speech synth. That's not a bad thing, it's kind of cool :)

  • @ProjectPhysX
    @ProjectPhysX 6 ปีที่แล้ว

    I have an array of lets say 8 threads all running infinite loops and I need to synchronize the threads multiple times within the loops, so the 7 fastest threads need to wait until the last one reached the synchronization point and then can continue. What is the best way to implement this?

    • @Bisqwit
      @Bisqwit  6 ปีที่แล้ว

      OpenMP would make this easy with its #pragma omp barrier keyword.
      EDIT: But if you would like to do it in standard C++, you would probably use a condition_variable or two, and an atomic counter. Each thread entering the barrier will increment the counter, use notify_all() on the condition variable, and if the counter is smaller than the expected number of threads, block on the condition variable. The thread will wake up any time a new thread enters the barrier and calls notify_all(). (It can also wake up spontaneously.) In such event, check if the counter has reached the expected number of threads, and if so, try_lock a mutex so a single thread will reset the counter to zero. That is the overall gist of it. It may need more details to it, but if I needed to do it, I would probably check what an existing OpenMP implementation actually does at the barrier.

  • @drewnoakes
    @drewnoakes 8 ปีที่แล้ว

    Another great video, thanks. Where is the C++ 3D engine video? I enjoyed your C video from a year back, but the footage you show here looks unfamiliar. Is that video available?

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      +Drew Noakes It's still work in progress. It's missing features (most importantly, moving actors, which are technically possible, it's just the rotation math and actual placement that is missing), and the core must be compacted a lot before it can be presented in any reasonable-length video.
      You can find bits of the current design here: twitter.com/RealBisqwit/status/687000747007946752

  • @nk361
    @nk361 8 ปีที่แล้ว

    Please more advanced tutorials! I love advanced tutorials but they're so tough to find.

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      +Neil Kline Any particular topic in mind?

    • @nk361
      @nk361 8 ปีที่แล้ว

      Lots of threads lol
      Collision detection for abstract shapes
      Lighting physics and creating working light sources
      Disk readers
      A compact installer for software
      Memory managment and memory leaks
      Multithreaded graphics
      2D collision with a quad-tree or similar
      Disk checker
      Checking port for listening services
      Checking for installed software and running code to use the installed software
      General file managment and naming schemes in c++ software projects
      Creating procedurally made objects that fit parameters
      Thank you in advance, you have some very valuable content already!

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      +Neil Kline Thanks! Be mindful though, that quite many of those topics are very platform-specific. I never do anything Windows-specific in my programming videos.

    • @nk361
      @nk361 8 ปีที่แล้ว

      Bisqwit I didn't know that, I'll be happy with any of them you decide to do. Also, if you come across some code with some sort of trick in it, I'd like to know. I've heard of someone using for loops as if else statements once. I don't know why though lol

  • @tomhijkl
    @tomhijkl 7 ปีที่แล้ว

    I miss programming videos a lot

  • @BronzeDoc
    @BronzeDoc 8 ปีที่แล้ว

    Love your videos Bisqwit, what is the font you use for coding?

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว +1

      +BronzeDoc I use -misc-fixed-bold-r-normal--15-140-75-75-c-90-iso8859-15 when coding. But I suspect that's not what you really wanted to know. You are asking about the font that is shown in DOSBox, which I use in video productions. DOSBox uses (a copy of) the ROM/BIOS font(s) that is built in all VGA compatible graphics cards, regardless of operating system, drivers and files.

  • @martinh7544
    @martinh7544 7 ปีที่แล้ว

    What console or IDE is that? It's great!

  • @nominatim538
    @nominatim538 8 ปีที่แล้ว

    Hello, Bisqwit. I'm a junior-to-middle C# developer and after watching your videos I've really wanted to learn C++ and create emulators. Which books about C++ and computer architecture would you recommend. Thanx a lot

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      +Lex Cerveza Sorry, I'm not much a book person myself, as nearly all of the material I use is free in the Internet. People have told me to recommend C++ Primer though. ISBN 9780321714114

  • @lupinedreamexpress
    @lupinedreamexpress 5 ปีที่แล้ว +1

    I pray for your health, a blood pressure machine and some medical cloth in the video is not a good sign. You are intelligent and need to be blessed to share more with the world.

    • @Bisqwit
      @Bisqwit  5 ปีที่แล้ว +3

      Thank you. The “cloth” is just an ordinary sheet, nothing medical about it. I do monitor my blood pressure sometimes.

    • @lupinedreamexpress
      @lupinedreamexpress 5 ปีที่แล้ว

      You're welcome. Question for you while you are awake. The MIDI file that is played in your typing game in the background, do you have that available ? I'm a composer and would like to give it a mix-up, with your permission ofcourse.

  • @losav96
    @losav96 7 ปีที่แล้ว +2

    +Bisqwit Hi, can you explain me why do you use "auto" type so often instead of int, char, long, etc. types? Is there a reason behind that? Thank you in advance, I'm here to learn :)

    • @Bisqwit
      @Bisqwit  7 ปีที่แล้ว

      The auto keyword is used when it is not relevant for the calling code to know precisely the datatype returned by a called function, or when it would be pointless to repeat that information multiple times in the program. Using "auto" gives greater freedoms to change the type later, with fewer changes to the program being necessary. It (usually) decreases the amount needed to type and (usually) makes the program more maintainable.

    • @losav96
      @losav96 7 ปีที่แล้ว

      Bisqwit Thank you! When "auto" came out (C++11/14) I saw "some Python" inside the C++.

  • @nthexwn
    @nthexwn 8 ปีที่แล้ว

    I'm currently writing a multi-threaded program where I have a boolean flag which I forgot to wrap inside a mutex lock. Curiously, it seems that one thread is always able to read this flag at the same time that another is writing to it.
    Initially I suspected that this was a race condition between the two threads which always favored one of the threads, but my understanding of context switching in most OS'es tells me that both threads aren't always necessarily executing at the same time anyway, so that wouldn't fully explain it.
    The code is also structured such that one thread reads the variable at very even intervals (based on monitor refresh rate) while the other thread writes to the variable quite sporadically (game calculations involving random numbers and such).
    This leads me to believe that, statistically speaking, there should be a collision between the two threads when accessing the flag after having run the program all night... But it still seems to work!
    My current guess is that the boolean flag fits inside the memory bus on my PC so that the hardware itself is making the read and write transactions atomic. Could this be true? If so, wouldn't there be a third case at 20:20 - 20:35 in the video?:
    "If the object being accessed by both threads is of a primitive type which takes up less memory than the bus width of all hardware devices on which your program is intended to be run, then you also don't need a mutex lock"
    I feel that this would still be a generally bad programming practice, but it does seem like it might be a fun trick to use when performance REALLY matters (probably not often though since I believe mutex locks only take O(1) execution time).

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว +1

      +Alexander Johnson So your case is that one thread is reading the variable and other thread is writing the variable (sporadically or not).
      Unless the reading thread uses one of the synchronization primitives (atomic, mutex, condition_variable), there's no guarantee that it will ever notice writes by the other thread.
      Unless the writing thread uses one of those synchronization primitives, there's no guarantee that any other thread ever notices those writes.
      Bus width has nothing to do with it. It's simply a matter of undefined behavior. (A practical explanation lies in variables fitting registers, spilling pressure etc, but it is irrelevant.)

  • @DusteDdekay
    @DusteDdekay 8 ปีที่แล้ว

    Great video, interesting subject indeed! :)
    I have a question, I've noticed your voice change when you explain the code on screen, and I wonder if you've made your own text-to-speech for this? It's your voice, but there's something different about it compared to when you talk in front of the camera.

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว +2

      +DusteDs Stuff When I talk on-camera, the speech is captured by the camera’s microphone at a distance of one meter. In other parts, the speech is captured by a headset microphone a couple of cm off my mouth, via a laptop's microphone jack, further postprocessed in Audacity to remove an extremely obnoxious 50 Hz noise (and other noise).
      In the on-camera scenes I also captured the speech with the headset, but because the camera's audio was surprisingly good enough, and there would have been lots of work to sync the computer audio to the camera audio (because each recording device has deviating timings for some reason), I discarded the headset audio for those parts.

    • @DusteDdekay
      @DusteDdekay 8 ปีที่แล้ว +1

      +piggy66 go show us something better.

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว +3

      +piggy66 Sorry man, but what is your problem? Noticing your other comment, you seem to be on a hostile mood. I hope everything is fine with you.

  • @vladimirfomene2847
    @vladimirfomene2847 7 ปีที่แล้ว

    Hello I saw a video where you implemented a DCPU-16 emulator and I will like to know how to do it? Where to start?

    • @Bisqwit
      @Bisqwit  7 ปีที่แล้ว

      You mean this? th-cam.com/video/MvDtr3cNaLU/w-d-xo.html
      Tip: Comment at the video you are talking about, so others who watch it can also benefit from the discussion relevant to the video.

  • @akapype
    @akapype 8 ปีที่แล้ว

    I would have hope std::atomic ...

  • @pchandu1995
    @pchandu1995 8 ปีที่แล้ว

    you're an insane programmer i ever seen, you have to stream in livecoding.tv.

  • @AlexNiebla
    @AlexNiebla 8 ปีที่แล้ว

    I am quite interested in knowing your setup, machine (hw, CPU, GPU, amount of GB of RAM, type of HDisk, screen size and resolution) your operating system, your code editor, that small keyboard .... just curious.

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว +2

      +Alex Niebla You know I'm using many computers. For instance, the computer connected to the little keyboard and the tiny display (actually a car reversing monitor) in the beginning is a Raspberry Pi. You can find a picture of that setup on my Twitter page.

  • @danaadalaide5648
    @danaadalaide5648 5 ปีที่แล้ว

    The curl c api isn't that bad, you have the easy functions and just set a callback or use a lambda

  • @shahabmeteor8975
    @shahabmeteor8975 4 ปีที่แล้ว

    Thanks a lot for your video, Is 200 Bytes is normal with your additional extra code? at the cost of cpu utilization?

    • @Bisqwit
      @Bisqwit  4 ปีที่แล้ว

      Sorry, but I don’t understand what you are asking. Can you try to be more clear?

    • @shahabmeteor8975
      @shahabmeteor8975 4 ปีที่แล้ว

      @@Bisqwit At 22:25 you compare cpu utilization with condition variables for busy loop, there is also memory beside, it has been increased 200 bytes I think, how is it explained? Thx

    • @Bisqwit
      @Bisqwit  4 ปีที่แล้ว +1

      I would not pay attention to the memory usage when the difference is that small. It is within error marginal. Differences can be caused by alignment/fragmentation losses in memory allocator. You can notice even the two successive runs had a different reading for memory use.

    • @shahabmeteor8975
      @shahabmeteor8975 4 ปีที่แล้ว

      @@Bisqwit Exactly, that was also strange to me, In any case it should be increased compare to without condition variables but it's complicated to understand how. Thank you for your clear explanation

  • @jaiggm
    @jaiggm 6 ปีที่แล้ว

    What distribution keyboard are you using for programming? Do you write so fast as the video is showing?

    • @Bisqwit
      @Bisqwit  6 ปีที่แล้ว

      I use qwerty, but these videos are tool-assisted performances.

    • @jaiggm
      @jaiggm 6 ปีที่แล้ว

      Thanks for the answer and thank you for the content. I'm learning a lot.

  • @huyvole9724
    @huyvole9724 6 ปีที่แล้ว +1

    You're Super Senior Programmer C++

  • @tw7522
    @tw7522 7 ปีที่แล้ว

    That's a nice keyboard. What brand is it?

    • @Bisqwit
      @Bisqwit  7 ปีที่แล้ว

      It is a cheap USB mini keyboard. I am having trouble locating the exact model again, but it is very similar to this: bisqwit.iki.fi/dx/p/241319

  • @eleganteatinginjapan659
    @eleganteatinginjapan659 6 ปีที่แล้ว

    Hello, I was wondering what "dltotal ? dlnow*100./dltotal : 0" does or to be more precise what the difference is between calling it with and without the dot before the division with the total bytes of the current file

    • @Bisqwit
      @Bisqwit  6 ปีที่แล้ว +1

      So you know the ternary expression, right? So let’s focus on the dot.
      The purpose of . is this: 100 and 100. are both numeric literals, but the type of 100 is int, while the type of 100. is double. What happens when you multiply an integer by an integer and divide by an integer? You get an integer. But when one of these values is a double, the result is a double as well.

    • @eleganteatinginjapan659
      @eleganteatinginjapan659 6 ปีที่แล้ว

      I've tried changing the format for the progress from int to double inside of the printf statement in my C Implementation and together with your explanation it makes sense. Thank you for your quick response, I got it now :D

  • @aham3687
    @aham3687 6 ปีที่แล้ว

    Sir, can you also make video on deep neural network?

    • @Bisqwit
      @Bisqwit  6 ปีที่แล้ว

      Maybe some day!

  • @viveks9048
    @viveks9048 8 ปีที่แล้ว

    Can someone tell me how cout is printing one line per thread? or how to do the samething using printf

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว +1

      +Vivek S In this program, Line() is a function that sets the cursor to a particular line using relative cursor movements only. (Or to be more precise, it generates escape codes, which, when outputted on screen, tell the terminal to move the cursor in such manner, assuming the terminal understands these escape codes.) Each thread, when printing, always begins their print with a call to Line(). That's how they each print to their own dedicated lines.

    • @viveks9048
      @viveks9048 8 ปีที่แล้ว

      +Bisqwit thanks for the quick reply, (i thought you were setting ln=1 inside line, but just now understood its ln=l)

  • @kafkawood
    @kafkawood 8 ปีที่แล้ว

    I like the camera angle change, very pro :) Whats that sphygmomanometer for?

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      +Gentleman Thanks! The blood pressure meter is a random prop I had laying on the table. In retrospect, I should have put a telephone there (which I did in my Patreon campaign video). I do actually use the gauge occasionally, because I have high blood pressure (and always had, to my knowledge). I have never heard that Greek-originating word before. Medical terminology in English is so weird and difficult.

    • @kafkawood
      @kafkawood 8 ปีที่แล้ว

      +Bisqwit The greek term is insane, agreed, provided by google translator :) Have you ever considered to put your programming skills to some stand-alone project? Or is it just individual problems that interest you?

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      I have made several stand-alone projects. You can find a (incomplete) listing here. bisqwit.iki.fi/src/

    • @kafkawood
      @kafkawood 8 ปีที่แล้ว

      +Bisqwit Cool, thanks. I see you are a fan of Go, what do you think about the recent defeat of champion by AI?

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      +Gentleman Hmm. I hadn’t finished watching the match yet, when your comment was posted, so you sort of spoiled the outcome to me, because I wanted to and did watch the whole match. Of course you had no way of knowing that.
      In any case, I have two viewpoints to this.
      As a Go player, this is tremendously exciting for me. The Japanese Go players are already calling the computer program AlphaGo-sensei. This is a title of respect given to anyone who is in a position of superior knowledge. The very prospect, that there might be a Go player who is stronger than any human player today, is exhilarating. It might even open up a new era in Go: For now there is a source of new ideas, a potential new world of theories of openings and other areas of play. It may entirely challenge some existing beliefs on how the game is to be played, as has happened on several occassions in the history. On the other hand, there is the scary possibility that AlphaGo is nothing more than a monument of technological prowess to Google, and that as soon as this publicity period is over, the resources allocated to it (which cost money) are directed to other things and that the Go players are left standing in the snow. This, too, is a thing that tends to happen with research projects driven by PR.
      As a programmer, I find this very exciting. I have tackled the problem of Go AI myself, and I have studied Go programs like GnuGo, and I know all about the problems that Go-playing AIs are facing. Among many other things, AlphaGo is using neural networks. I have personally tried to use the same idea years ago for Go AI, but neural networks are still somewhat black magic to me. I’m not quite sure what makes them tick. Neural networks are doing some very impressive things today, particularly in the area of image processing. The concept of emergent intelligence is at the core here. I’m not sure what to make of it. Until I can figure out what’s the deal, there is a real chance that this whole thing may end up challenging my beliefs on things like evolution and singularity. As a programmer I would like to put my spoon in the soup and hands in the dough, but like I said, neural networks are still somewhat a mystery to me. I have read articles, and I have read mathematics, and I have studied source code of numerous libraries, but I am still not there yet.

  • @DFsdf3443d
    @DFsdf3443d 5 ปีที่แล้ว

    is that vim you are using?

    • @Bisqwit
      @Bisqwit  5 ปีที่แล้ว

      nope

  • @KishoreG2396
    @KishoreG2396 5 ปีที่แล้ว

    Why use an anonymous namespace instead of a static function?

    • @Bisqwit
      @Bisqwit  5 ปีที่แล้ว

      With the “static” keyword you can only limit functions and variables into the current compilation unit. With an anonymous namespace you can also limit classes and other type names.
      Personally I use “static” unless I need also the latter, but I digress; it is not so important to me.

  • @ppBizU
    @ppBizU 8 ปีที่แล้ว

    I am looking at a clock in an editor (or TTY). Do you really write a program so fast?!

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      +ppBizU Watch this video to find out how I make programming videos: th-cam.com/video/5Da6ZyQJjE0/w-d-xo.html

    • @ppBizU
      @ppBizU 8 ปีที่แล้ว

      +Bisqwit Thank you!

  • @mr.unkreativ718
    @mr.unkreativ718 7 ปีที่แล้ว

    can´t you just make the std::vector atomic?

    • @Bisqwit
      @Bisqwit  7 ปีที่แล้ว +1

      There are two ways to do that: with locks, and lockless. Adding locks is easy, and making a lockless container may require a total redesign. No matter which one you choose, chances are there is going to be some performance penalty. There is no way std::vector could be atomic for all datatypes without performance penalties. C++ works by the principle that you only pay for what you use. If you need thread-safety, you’ll add your wrappers around the class that guard against simultaneous access. If you don’t need it, then you don’t add that, and you will not pay the penalty.

  • @imode256
    @imode256 8 ปีที่แล้ว

    The bottom-left annotation links to your Doom tutorial, but shows a different video..? It looks like the OpenGL scene you worte a while back.

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      +Ryan Jones Actually the link changes in the middle of the clip, as does the scene. :-)

    • @imode256
      @imode256 8 ปีที่แล้ว

      +Bisqwit Ah! Was wondering how you did the non-Euclidean geometry without a portal renderer. Thanks!

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      +Ryan Jones Well, what you see in that clip is all rendered in one go with a single program. You'll see what it's really about when the time comes. :-)

    • @imode256
      @imode256 8 ปีที่แล้ว

      Bisqwit
      :D! Exciting!

  • @huyvole9724
    @huyvole9724 6 ปีที่แล้ว

    Aha new keyboard !!!

    • @Bisqwit
      @Bisqwit  6 ปีที่แล้ว

      It‘s the same keyboard that I used in the most watched video from my channel. In other words, not very new.

  • @He4rtRock
    @He4rtRock 4 ปีที่แล้ว

    great mousepad

  • @kaustubhken
    @kaustubhken 6 ปีที่แล้ว

    hii what is your view on rust programming language.

    • @Bisqwit
      @Bisqwit  6 ปีที่แล้ว

      I have tried it a bit when I made this video. th-cam.com/video/Ex1iFZuUdJ4/w-d-xo.html
      It feels clever and awkwardly stiff at the same time. Like Pascal, but better.

    • @kaustubhken
      @kaustubhken 6 ปีที่แล้ว

      Bisqwit thanks for your quick reply, I played Prince of Persia and Aladdin many times on DOS in 1997-98 😀

  • @iProgramInCpp
    @iProgramInCpp 4 ปีที่แล้ว

    What's the S suffix at the end of strings? Is it just to mark that the things in quotes should be treated as a std::string, instead of a char*?

    • @Bisqwit
      @Bisqwit  4 ปีที่แล้ว

      It means the compiler will insert a std::string construction there, and the expression has the type std::string.
      For example, "mocha"s is the same as if you typed std::string("mocha", 5).
      Notice the number 5, which is inserted by the compiler. It is the length of the string. If you did std::string("mocha"), the program would have to calculate the length of the string at runtime, because all it sees is a nul-terminated character pointer.
      It’s just a tiny thing, but good to be aware of. This does require that one additional line though, using namespace std::literals::string_literals;. Which can be shorted to: using namespace std::string_literals; (which I didn’t know when making this video).

    • @iProgramInCpp
      @iProgramInCpp 4 ปีที่แล้ว

      @@Bisqwit Sounds interesting. Maybe adding that makes the program more stable/efficient? That's cool regardless.

    • @Bisqwit
      @Bisqwit  4 ปีที่แล้ว

      Totally a trifle. But it is attention to many of these small things that makes one a professional programmer.

    • @iProgramInCpp
      @iProgramInCpp 4 ปีที่แล้ว

      @@Bisqwit trifle? Sorry, English is not my native language.

    • @Bisqwit
      @Bisqwit  4 ปีที่แล้ว

      www.google.com/search?q=trifle

  • @brucen83
    @brucen83 7 ปีที่แล้ว

    dude i like you your weird accent, i dont really use c++ for anything - but i have done some simple stuff with it in the past, but this was a nice recommendation from youtube. what do you do for a living?

    • @Bisqwit
      @Bisqwit  7 ปีที่แล้ว

      I do actually do C++ for living right now. But I have also done other things, not all even programming related.

  • @VitisCZ
    @VitisCZ 8 ปีที่แล้ว

    What is the text font? Kupo! :D

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      Standard EGA/VGA fonts supplied by DOSBox, an emulator for IBM PC, under which all the console footage shown here was recorded. These fonts exist in the ROM BIOS of every single graphics card of today's PCs.

  • @Aerospyke
    @Aerospyke 8 ปีที่แล้ว +5

    Thanks for the video! Have you considered starting a patreon account so I can send a few euros your way?

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว +3

      +Aerospyke I do in fact have one already at www.patreon.com/Bisqwit . (Just in case, so someone else doesn't take the name.) But I haven't advertised it anywhere because I haven't yet thought of content to put on that page. Thank you very much for your consideration!

  • @KishoreG2396
    @KishoreG2396 4 ปีที่แล้ว

    19:26 How can you call std::async() without asking the main thread to "join" with the thread that async launches? Why is that only necessary when creating "std::thread" objects? How would the main thread automatically know to "join" with the thread that async launches? Is there RAII happening here somewhere?
    Also, in what situation would one want to use std::async without specifying std::launch::async nor std::launch::deferred (meaning that the default will be implementation defined, or equivalent to std::launch::async | std::launch::deferred)? What is the purpose of the standard providing the default for std::async to be implementation defined and out of the control of the programmer rather than making the default std::launch::async, since most people want it to start an asynchronous task?

    • @Bisqwit
      @Bisqwit  4 ปีที่แล้ว

      std::thread does not need to wait for the thread either, if you call its .detach() method. However, std::async() returns an _object_ that incorporates some kind of reference to the thread. When you call the .wait() or .get() method on that object, it essentially does the same as the .join() method for std::thread, except it also returns the value (and launches the thread first, if it was a deferred async method).
      As for why there is no default, no idea.

    • @KishoreG2396
      @KishoreG2396 4 ปีที่แล้ว

      @@Bisqwit Yes, std::async returns a future.. But if you had code in main that was just an async() call, and nothing more (you don't call "wait" or "get" on the retrieved future object), then the program still works without abruptrly ending or throwing an exception. Why is that?
      Normally, with std::thread, if you launch an std::thread in main() and you don't call join() or detatch(), the program will just throw an exception and abort. However, with async, the program automatically seems to join() with the thread called by async() even if you don't do anything with the future object returned by async(). Why is that? Here is an example code:
      onlinegdb.com/HJUQlLSsU
      As you can see in the main function, we retrieve the future object, but we never call wait() on it. Yet the main() thread still waits for new_thread() to finish before getting to the "return 0" statement. Why is that?

    • @Bisqwit
      @Bisqwit  4 ปีที่แล้ว

      If you have just an async() call, it still returns a value. If you don’t store that value in a variable, then the destructor of the returned object is called. For a std::future created by std::async, the destructor will block until the return value of the asynchronous function becomes available. In other words, the destructor of std::future will wait for the thread.

    • @KishoreG2396
      @KishoreG2396 4 ปีที่แล้ว

      @@Bisqwit I see. Does the destructor of the future only do that for async() calls, not any other calls?

    • @Bisqwit
      @Bisqwit  4 ปีที่แล้ว

      That’s how I understand it.

  • @kallebanan1924
    @kallebanan1924 8 ปีที่แล้ว

    What does the text in the intro mean? I think it's hebrew but I'm not sure.

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว

      +anton adamson It is from Isaiah 12:3.

    • @kallebanan1924
      @kallebanan1924 8 ปีที่แล้ว

      Bisqwit "With joy you will draw water
      from the wells of salvation."

  • @Tudorgeable
    @Tudorgeable 8 ปีที่แล้ว

    Modern operating systems like Linux, as opposed to what? DOS?

    • @Bisqwit
      @Bisqwit  8 ปีที่แล้ว +1

      +Tudorgeable Yes. This was my tale from mid-90s.

  • @SkillTrailMalefiahs
    @SkillTrailMalefiahs 7 ปีที่แล้ว

    Bisqwit pls u have tutorial... how to used you editor?

    • @Bisqwit
      @Bisqwit  7 ปีที่แล้ว +1

      For the most part, the same way you would use Joe. The list of keys is available here. bisqwit.iki.fi/jutut/kuvat/programming_examples/e_editor/keys.txt
      But the best way to _use_ it is to uninstall it and use an editor that is _actually_ designed to be used by people. E is designed to be used as a video production middle-end.

    • @SkillTrailMalefiahs
      @SkillTrailMalefiahs 7 ปีที่แล้ว

      Thank you very much friend!
      Brother and I can run it on windows 10?

    • @Bisqwit
      @Bisqwit  7 ปีที่แล้ว

      E? You can run it in a DOS emulator. It's a DOS program.
      Joe? You can run it under Cygwin or Mingw. Perhaps even under the touted "Windows Subsystem for Linux". For best experience, switch to an actual operating system that is not encumbered with closed source software and annoying license politics dictated by a money-making motivated vendor.

    • @SkillTrailMalefiahs
      @SkillTrailMalefiahs 7 ปีที่แล้ว

      I'm new to programming I do all this for hobby and because I want to learn for the moment I would not do anything for profit! ...
      (E.exe) I want to use it because I like the way you program and I want to practice as you do!
      I am from Venezuela!

    • @Bisqwit
      @Bisqwit  7 ปีที่แล้ว +1

      There is no magic whatsoever in the editor. It's just a screen on which you type. You can use Notepad++.