# coroutine

- **İngilizce aslı:** https://wiki.facepunch.com/gmod/coroutine
- **Çeviri tarihi:** 2025-09-08

Coroutineler, thread'lere benzer ancak eş zamanlı olarak çalışmazlar. Görevleri bölmek ve fonksiyonları dinamik olarak duraklatıp & devam ettirmek için bir yol sunarlar.

## Metotlar

[thread](https://gmod.tr/wiki/thread) coroutine.[create](https://gmod.tr/wiki/coroutine.create)( [function](https://gmod.tr/wiki/function) func )

Verilen fonksiyondan bir coroutine oluşturur.

[boolean](https://gmod.tr/wiki/boolean) coroutine.[isyieldable](https://gmod.tr/wiki/coroutine.isyieldable)()

Çalışan coroutine'in yield edilip edilemeyeceğini döndürür. Çalışan bir coroutine, ana thread'de değilse ve yield edilemeyen bir C fonksiyonu içinde değilse yield edilebilir. Bu, LuaJIT sürümündeki farklılık nedeniyle yalnızca x86-64 sürümlerinde mevcuttur. Buraya bakın

[boolean](https://gmod.tr/wiki/boolean), [vararg](https://gmod.tr/wiki/vararg) coroutine.[resume](https://gmod.tr/wiki/coroutine.resume)( [thread](https://gmod.tr/wiki/thread) coroutine, ... )

Verilen coroutine'i devam ettirir ve verilen argümanları, ya fonksiyon argümanlarına ya da fonksiyonun içindeki `coroutine.yield`'e iletir. Bir sonraki `yield` çağrısı veya fonksiyondaki `return` ile ne döndürülürse onu geri döndürür.

[thread](https://gmod.tr/wiki/thread) coroutine.[running](https://gmod.tr/wiki/coroutine.running)()

Aktif coroutine'i veya bir coroutine içinde değilsek nil değerini döndürür.

[string](https://gmod.tr/wiki/string) coroutine.[status](https://gmod.tr/wiki/coroutine.status)( [thread](https://gmod.tr/wiki/thread) coroutine )

Kendisine iletilen coroutine'in durumunu döndürür; olası durumlar "suspended" (askıya alındı), "running" (çalışıyor) ve "dead" (sonlandı) şeklindedir.

coroutine.[wait](https://gmod.tr/wiki/coroutine.wait)( [number](https://gmod.tr/wiki/number) duration )

Devam etmeden önce coroutine'i belirtilen süre boyunca tekrar tekrar yield eder. Sadece bir coroutine içinde çalışır. Yalnızca nextbot coroutine think fonksiyonlarında kullanışlıdır. Bu fonksiyon, RealTime yerine CurTime kullanır.

[function](https://gmod.tr/wiki/function) coroutine.[wrap](https://gmod.tr/wiki/coroutine.wrap)( [function](https://gmod.tr/wiki/function) coroutine )

Çağrıldığında, `coroutine.resume`'i coroutine ve tüm ekstra parametrelerle çağırmaya eşdeğer olan bir fonksiyon döndürür. Döndürülen fonksiyon tarafından geri verilen değerler, yalnızca iç coroutine'in `yield` çağrısına iletilen değerleri içerir ve `coroutine.resume`'in sağladığı hatasız durumunu içermez. Başarısızlık durumunda bunun yerine bir hata fırlatılır.

[vararg](https://gmod.tr/wiki/vararg) coroutine.[yield](https://gmod.tr/wiki/coroutine.yield)( ... )

Aktif coroutine'i duraklatır ve tüm ek değişkenleri, coroutine'i en son devam ettiren `coroutine.resume` çağrısına iletir. Ayrıca, önceki `resume` çağrısına iletilen tüm ek değişkenleri geri döndürür.

- [GMod Wiki ana sayfası](https://gmod.tr/wiki)

---

[Tüm sunucular](https://gmod.tr/) · [GmodTR Launcher](https://gmod.tr/launcher) · [Rehber](https://gmod.tr/rehber) · [GMod Wiki](https://gmod.tr/wiki) · [GmodTR nedir?](https://gmod.tr/hakkinda) · [Sunucu ekle](https://gmod.tr/sunucu-ekle) · [Discord](https://discord.gg/gmodtr)

Kaynak: https://gmod.tr/wiki/coroutine
