Back to Browse

Goroutine (concurrent programming) | GoAPI Essential EP. 6

12.0K views
Dec 23, 2023
1:19:05

☕️ สนับสนุนช่องเราด้วยการสมัครสมาชิกช่องทางนี้ได้เลย https://www.youtube.com/channel/UC3YgTINPYQmUcRt5ZcNFIZQ/join สวัสดีสู่ตอนที่ 6 ของซีรีย์ GoAPI Essential หัวข้อนี้จะเป็นการเรียนรู้การเขียนโปรแกรมแบบ Concurrent programming ผ่าน goroutine อีก 1 feature ของภาษา Go ที่ช่วยทำให้โปรแกรมสามารถทำงานแบบ Concurrent ได้กัน ! โดยในหัวข้อนี้จะประกอบไปด้วย 1. แนะนำ concurrent programming และ goroutine 2. รู้จัก channel กับใช้งานคู่กับ goroutine 3. การใช้ Sync package (Mutex, Cond, Once, WaitGroup) 4. การประยุกต์ใช้ goroutine ให้เป็น pubsub และ cronjob ขอให้ทุกคน Enjoy กับการเรียนรู้ครับ ho ho ho 😘 หัวข้อ 00:00 แนะนำ Session / การเขียนโปรแกรมแบบ Concurrent 03:14 Session นี้จะพูดประเด็นไหนบ้าง 04:41 เริ่มต้นรู้จัก goroutine 08:53 แนะนำ Channel 11:36 ปัญหา Deadlock กับการบริหาร Buffer Channel 14:10 การใช้ Channel กับ goroutine 19:38 เพิ่มเติม Deadlock กับ channel ใน goroutine 20:51 การใช้ loop รับข้อมูล channel กับ goroutine 23:35 การใช้ select กับ goroutine 28:48 แนะนำ Sync package (ตัวเสริมจัดการ goroutine) 30:38 1. Mutex สำหรับการ Lock resource 31:00 2. Cond สำหรับการทำ condition goroutine 31:19 รู้จักปัญหา Race condition และ Wait state 34:39 3. Once สำหรับการ run function ใน goroutine เพียงครั้งเดียว 35:00 4. WaitGroup สำหรับการรอ goroutine 36:33 ตัวอย่าง code - WaitGroup 39:49 ตัวอย่าง code - Mutex 44:50 ตัวอย่าง code - Once 47:29 ตัวอย่าง code - Cond 51:36 เพิ่มเติมกับ Mutex guard condition 52:24 สรุปปัญหา Deadlock มีโอกาสเกิดจากเคสไหนบ้าง 54:40 มาประยุกต์ใช้กับ pubsub 57:17 ทำ pubsub ร่วมกับ Fiber API 1:06:02 มาประยุกต์ใช้กับ cronjob 1:12:06 ใช้ cronjob ร่วมกับ GORM 1:15:12 แนะนำอื่นๆเกี่ยวกับ goroutine 1:17:55 สรุปหัวข้อ สำหรับใครอยาก follow ตามเอกสาร สามารถเข้ามาอ่านกันได้เล้ยที่นี่ https://docs.mikelopster.dev/c/goapi-essential/chapter-6/intro ใครมีข้อสงสัยเพิ่มเติม มาพูดคุยแลกเปลี่ยนความรู้กันได้ที่ Facebook page: https://www.facebook.com/mikelopster.dev Website: https://mikelopster.dev พิกัดของด้านหลัง : https://shope.ee/8A54c8cfkf

Download

0 formats

No download links available.

Goroutine (concurrent programming) | GoAPI Essential EP. 6 | NatokHD