Ruby 3 is awesome! Writing cooperative multitasking with Fibers is easy.

I wanted to try the new ruby 3 and the Fiber.scheduler.

The documentation is lacking, it took me several days to understand whats happening.

But in the end I was able to understand it more or less.

And wrote an MQTT client, which turned out to be very easy. The network communication is straightforward with Fibers.

Take a look: https://github.com/jsaak/ruby-mqtt3/blob/master/ruby-mqtt3.rb

edit: it seems that people expect a hello world, hold my hands type article here. This is not it.

If you want that, I found these:

https://rubyreferences.github.io/rubychanges/3.0.html#non-blocking-fiber-and-scheduler

https://www.youtube.com/watch?v=Y29SSOS4UOc

https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/

http://www.wjwh.eu/posts/2020-12-28-ruby-fiber-scheduler-c-extension.html

πŸ‘︎ 53
πŸ’¬︎
πŸ‘€︎ u/jsaak
πŸ“…︎ Mar 08 2021
🚨︎ report
Coop: C++20 coroutines-based library to support cooperative multitasking in the context of a multithreaded application github.com/jeremyong/coop
πŸ‘︎ 18
πŸ’¬︎
πŸ‘€︎ u/m_ninepoints
πŸ“…︎ Mar 01 2021
🚨︎ report
Announcing juggle v0.1.0, async cooperative multitasking library. crates.io/crates/juggle
πŸ‘︎ 52
πŸ’¬︎
πŸ‘€︎ u/Kazik24
πŸ“…︎ Sep 15 2020
🚨︎ report
Cooperative multitasking using coroutines (in PHP!) nikic.github.io/2012/12/2…
πŸ‘︎ 12
πŸ’¬︎
πŸ‘€︎ u/sicilian_najdorf
πŸ“…︎ Feb 12 2020
🚨︎ report
Asynchronous programming. Cooperative multitasking luminousmen.com/post/asyn…
πŸ‘︎ 11
πŸ’¬︎
πŸ‘€︎ u/luminoumen
πŸ“…︎ Apr 04 2020
🚨︎ report
Are cooperative synchronization and cooperative multitasking the same thing?

I'm asked about cooperative synchronization in regards to concurrency, however this doesn't seem to be a very popular term. I want to be sure I don't gather the wrong information. Any resources covering the topic would be greatly appreciated as well.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/YeetYertMcGert
πŸ“…︎ Dec 23 2019
🚨︎ report
Blog: Implementing cooperative multitasking in Rust gmorenz.gitlab.io/coop.ht…
πŸ‘︎ 116
πŸ’¬︎
πŸ‘€︎ u/gmorenz
πŸ“…︎ Jun 17 2017
🚨︎ report
php-service-bus v2.2.7 released Cooperative multitasking framework, that lets you implement an asynchronous messaging, a transparent workflow and control of long-lived business transactions by means of the Saga pattern. It implements the [message based architecture github.com/mmasiukevich/s…
πŸ‘︎ 35
πŸ’¬︎
πŸ‘€︎ u/mmasiukevich
πŸ“…︎ Dec 13 2018
🚨︎ report
An Introduction to Cooperative Multitasking with Kotlin Coroutines blog.pronghorn.tech/coope…
πŸ‘︎ 30
πŸ’¬︎
πŸ‘€︎ u/c_a_turner
πŸ“…︎ Apr 20 2018
🚨︎ report
A2osX: cooperative, event-driven multitasking OS for Enhanced IIe (65C02 CPU) with 128 KiB, //c, IIgs github.com/burniouf/A2osX
πŸ‘︎ 20
πŸ’¬︎
πŸ‘€︎ u/BrianKrent
πŸ“…︎ Jul 31 2017
🚨︎ report
Cooperative multitasking (x-post AnimalsBeingPolite)
πŸ‘︎ 117
πŸ’¬︎
πŸ‘€︎ u/robhol
πŸ“…︎ Apr 14 2015
🚨︎ report
Cooperative multitasking using coroutines nikic.github.com/2012/12/…
πŸ‘︎ 31
πŸ’¬︎
πŸ‘€︎ u/nikic
πŸ“…︎ Dec 22 2012
🚨︎ report
A simple cooperative multitasking kernel github.com/fhars/dcos16
πŸ‘︎ 12
πŸ’¬︎
πŸ‘€︎ u/fhars
πŸ“…︎ Apr 09 2012
🚨︎ report
ELI5: What is the difference between cooperative and preemptive multitasking OSes and what are their benefits/caveats?

I've been reading through this post that asks mainly about how preemptive multitasking works and decided to do a little bit of reading on the wiki. I saw a few mentions of cooperative multitasking, mostly about it being used in Windows and Mac versions prior to Win95 and OSX, respectively. What I got from reading about cooperative multitasking is that apps were more prone to locking up the OS as a whole, but other than that the whole concept is still clear as mud to me. Why are cooperative apps more prone to taking down a whole computer as opposed to apps in a preemptive environment? Is there an advantage that a cooperative multitasking OS has over a preemptive one, and if not, why didn't companies like MS and Apple use preemption in their OSes in the first place? Are there any recent OSes that still use cooperative multitasking today?

πŸ‘︎ 2
πŸ’¬︎
πŸ“…︎ Oct 08 2014
🚨︎ report
Async – Cooperative Multitasking for Hack and Async Curl. hhvm.com/blog/7091/async-…
πŸ‘︎ 24
πŸ’¬︎
πŸ‘€︎ u/magnetik79
πŸ“…︎ Dec 05 2014
🚨︎ report
Cooperative Multitasking for Hack hhvm.com/blog/7091/async-…
πŸ‘︎ 7
πŸ’¬︎
πŸ‘€︎ u/ange1a
πŸ“…︎ Dec 05 2014
🚨︎ report
a for fun new tiny 10 minutes cooperative multitasking framework for PHP 7 github.com/alash3al/axync
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/alash3al
πŸ“…︎ Feb 18 2016
🚨︎ report
"multitask" allows Python programs to use generators (aka coroutines) to perform cooperative multitasking and asynchronous I/O o2s.csail.mit.edu/o2s-wik…
πŸ‘︎ 41
πŸ’¬︎
πŸ‘€︎ u/lost-theory
πŸ“…︎ May 25 2007
🚨︎ report
Async – Cooperative Multitasking for Hack hhvm.com/blog/7091/async-…
πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/jvwatzman
πŸ“…︎ Dec 05 2014
🚨︎ report
Python Generators - From Iterators to Cooperative Multitasking lgiordani.github.io/blog/…
πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/lgiordani
πŸ“…︎ Feb 14 2014
🚨︎ report
Game state management using cooperative multitasking sharp-gamedev.blogspot.co…
πŸ‘︎ 8
πŸ’¬︎
πŸ‘€︎ u/ethicszen
πŸ“…︎ Feb 13 2011
🚨︎ report
POE is a Perl framework for reactive programs, cooperative multitasking, and network applications. poe.perl.org/?What_POE_Is
πŸ‘︎ 12
πŸ’¬︎
πŸ‘€︎ u/gst
πŸ“…︎ Jun 14 2009
🚨︎ report
Cooperative multitasking using the Eventually workflow sharp-gamedev.blogspot.co…
πŸ‘︎ 7
πŸ’¬︎
πŸ‘€︎ u/ethicszen
πŸ“…︎ Jan 22 2011
🚨︎ report
Vintage Apple Macintosh + Raspberry Pi v.redd.it/5p1stal6z9f61
πŸ‘︎ 2k
πŸ’¬︎
πŸ‘€︎ u/hungryim
πŸ“…︎ Feb 03 2021
🚨︎ report
Does PHP really not support asynchronous calls natively?

Hello :)

I have quite an advanced general question about PHP. I was writing an article about Python for a PHP audience and when it came to talking about Python's native async modules I wanted to write quite naively that PHP does not support async natively.

Then I wondered if it was really true and I went down the rabbit hole.

From what I read in different places, one thing that allows async for a language is to have coroutines. PHP supports them since 5.5 thanks to generators and allows not only to pause the state of a function and get a value from it, but also send back a value to this function in its paused state. Nikita Popov made an interesting (but quite complicated) article about it here in 2012.

I also read the Fibers RFC (implemented now) which seems to bring an easier way to control the flow of functions. Then I read this article about Fibers which at some point clearly states:

>Now, the fiber API itself does not provide such an event loop (which I consider a good thing).
This means you would still have to use something like ReactPHP, Swoole or Amp to provide async execution models or to build anything that can actually execute concurrently. This means that with or without fibers, async PHP will be provided by external libraries.

So I came to the conclusion that what PHP misses right now to have a real async native support is the event loop, but the rest is present in the language. I never used async PHP but I checked the Swoole library and the tool requires a specific pecl extension (`swoole`). On the other hand, for ReactPHP no extension is necessary: their event loop seems to run on native PHP.

So I have several questions:

- Am I right when I say that what PHP mainly misses for async support is an event loop (which Python and node have)?
- Is it planned to add some day a native event loop to PHP?
- If we are able with PHP code (with libraries like ReactPHP but without extensions) to do async programming, can we really say the language does not support async natively?

It's a quite complicated topic for me so sorry if some of my questions do not make sense.
If someone can help me understand a bit more how all this works I would be really glad, thank you! :)

πŸ‘︎ 65
πŸ’¬︎
πŸ‘€︎ u/kalcora
πŸ“…︎ May 06 2021
🚨︎ report
How does a single core processor schedule work?

In the old days when we only had single core processors, how would a processor schedule a task and then know to go back to windows scheduler (or OS of choice) and get another task?

Did it have some small cache of code that told it once it was done doing a task to go back to windows scheduler and compute a new one?

How did a single core know how to jump around so quickly from task to task to give the appearance of "multiple programs running simultaneiously" even though the precessor could only compute one task at a time.

I guess I don't understand how it could know to say, do a math problem for one program, then know what task to do next. If windows scheduler was a program in itself, how does a processor know to do a task and then not just "forget" windows scheduler if technically while it was working on another task, it couldn't be running scheduler at the exact same time to tell it what comes next.

πŸ‘︎ 21
πŸ’¬︎
πŸ‘€︎ u/DieMadAboutIt
πŸ“…︎ Jan 17 2021
🚨︎ report
Proofing upper bound of execution time

I've been thinking about a problem for some time now and failed miserably with even writing a minimal example.

The general idea is to write a scheduler with real time cooperative multitasking. This means functions yield control back voluntarily within a fixed time period. Since this would be boring on its own, I wanted to ensure, that only those functions can be scheduled, which can guarantee, that they will yield within a time span, which is (given possibly constrained inputs) always shorter then the minimum time announced to the scheduler. The scheduler itself is doable. However I am struggling to express the proof for the execution time boundary for a function in the type signature (or as a dependent pair). I wouldn't mind writing a simple interpreter/machine model and perform static code analysis to find an upper bound of execution speed, however I would like to stay within the language and not proof properties of the compiled code. But this is hard since I cannot pattern match on the function body.

Maybe there are also some ways of using quantitative type theory for this?

Of course there will be examples for which no such proof exists. This is totally fine. Up to now I am totally happy with examples like Fibonacci or even simple O(1) functions. Just something I can start thinking about.

So has anyone got an idea how one could tackle this problem? I am happy for any suggestion.

πŸ‘︎ 9
πŸ’¬︎
πŸ‘€︎ u/wechselstrom
πŸ“…︎ Apr 29 2021
🚨︎ report
The Instar Society: An Invitation

Topic: The Instar Society: An Invitation

In: Boards β–Ί Practitioner Organizations β–Ί Recruitment by babelytra:

Hello! I'm here on behalf of the Instar Society, a loose global organization of Practitioners helping each other take some of the danger out of self-modification. We tend to attract halflight Practitioners or those who work with insects, but neither one of those is a requirement. We're looking for more members, and this forum was recommended to me as a place to find Practitioners who might be interested in joining.

Summary

The core ritual that brings the Instar Society together is the Ecdysis ritual: a powerful and versatile halflight Practice somewhere between Citation and Shadow of Oneself. It allows a Practitioner in our Society (an "Instar") to call upon the remote assistance of other Instars to reshape one's own form or Self. Again, familiarity with other halflight Practices is not necessary.

Some of our members use Ecdysis to repeatedly alter their bodies in preparation for a final transcendent metamorphosis, at which point they become fully Other. Instars who wish to retain our Practice instead use Ecdysis to hone our Practice in various ways, transforming our immaterial rather than visceral Selves.

After performing an Ecdysis on one's Self with some total number of participants, an Instar must support an equal number of other Instars' Ecdysis rituals before they are eligible for Society support in another Ecdysis of their own. This model encourages our members to set aside time to help each other progress and ensures that new members are well-supported in their first Ecdysis.

We ask that Instars swear oaths to not harm other Instars while in Ecdysis, to cooperate with the Instar who called them there, and to not spread personal information we learn there. However, if you are called to assist and find your caller's actions or intentions objectionable, you may deny them your assistance and exit the ritual early.

If what you've read so far interests you, read on for a more thorough explanation of what Ecdysis entails and how the Instar Society can help.

---

Exuviae

To perform Ecdysis, you will first need to obtain one Exuviae per ritual participant. This generally means you plus two helpers.

To obtain an Exuviae, you will need to draw a diagram (provided to those who have sworn the Instar Society's oaths) around a live animal as it is about to molt. The more extreme the animal's transformation is, the more power

... keep reading on reddit ➑

πŸ‘︎ 20
πŸ’¬︎
πŸ‘€︎ u/The_Inventor
πŸ“…︎ Apr 12 2021
🚨︎ report
[Pinwheel] Birds of Prey | Ch1

Hi, I'm new to this subreddit (and reddit in general). I was recently introduced to this community, and I happen to have quite a lot of content that aligns with its themes. I thought I'd start posting some of it here chapter by chapter and see if you guys like it. I'm starting off with the most HFY-themed one, Birds of Prey. It's part of an ongoing sci-fi series, but all of my stories can also be read standalone. Please note that it does contain NSFW/Pancakes later in the story, but those scenes are confined to their own chapter which can be safely skipped. The links included below are to relevant concept art of species and vehicles from the setting.

Now also available on Royal Road: https://www.royalroad.com/fiction/43057/birds-of-prey

A UNN fleet on routine patrol near the outskirts of Coalition space encounters a previously uncontacted civilization, but while the aliens seem friendly, the Betelgeusian hive fleet that's sizing up their homeworld is not. Undersupplied and months from the nearest reinforcements, the fleet must coordinate with the locals in order to organize a last-ditch defense of the planet.

Book cover: http://snekguy.com/wp-content/uploads/2020/12/bop-h_guetzli.jpg

CHAPTER 1: U.F.O

The alarm blared, the sound of boots hammering on the deck joining the siren as the hangar bay was filled with a rush of activity. The running figures and idle spacecraft were illuminated by flashing, orange warning lighting, instructions coming through on loudspeakers and radios as the personnel hurried to their positions.

Jaeger was already wearing his helmet, double-checking the seals on his flight suit as he made his way towards his plane, listening to the chatter in his ear.

β€œ...heat signatures in the Oort cloud, nothing showing up on radar, but there's a lot of interference from small bodies and debris...”

Just like with every long-range patrol, or Bug hunts as they were colloquially known, the UNN Rorke had been drifting along the edge of Coalition space and scanning for Betelgeusian activity for weeks now with no contacts. Jaeger was itching to get back into the cockpit, to stretch his wings in the black void of space. Being cooped up inside the jump carrier was nearly enough to drive him crazy.

His chest swelled with excitement as he arrived beside his ship, its angular, black chassis making it look like it had been chiseled from a block of solid onyx. The airframe was designed for the lowest possible radar cross-section, the swep

... keep reading on reddit ➑

πŸ‘︎ 75
πŸ’¬︎
πŸ‘€︎ u/Snekguy
πŸ“…︎ Apr 10 2021
🚨︎ report
She seems to be having a field day out there.
πŸ‘︎ 4k
πŸ’¬︎
πŸ‘€︎ u/fedamasavasol
πŸ“…︎ May 17 2021
🚨︎ report
(Warning: Morbid dad joke) True Story -- My family were planning my mum's funeral. We always try to keep things light and try to stay positive, just as Mum would have it...

The funeral director was asking us what we think Mum should wear in her casket.

Mum always loved to wear sarongs (fabric wraps that go around the torso and drape downward a bit like a long skirt would), so my uncle suggested that she wear a sarong in there.

The funeral director looked a bit confused, as did some of our family members, to which my uncle added:

"What's sarong with that?"

I started laughing like an idiot. He was proud of it too. The funeral director was rather shocked. We assured her, and our more proper relatives, that Mum would've absolutely loved the joke (which is very true).

His delivery was perfect. I'll never forget the risk he took. We sometimes recall the moment as a way help cushion the blows of the grieving process.

--Edit-- I appreciate the condolences. I'm doing well and the worst is behind me and my family. But thanks :)

--Edit-- Massive thanks for all the awards and kind words. And the puns! Love 'em.

πŸ‘︎ 12k
πŸ’¬︎
πŸ‘€︎ u/zipflop
πŸ“…︎ May 12 2021
🚨︎ report
If my son ever came out to be trans then I wouldn’t have a son anymore

I would have a daughter

πŸ‘︎ 7k
πŸ’¬︎
πŸ‘€︎ u/Captbeauner
πŸ“…︎ May 07 2021
🚨︎ report
Ah yes, pretty hip
πŸ‘︎ 8k
πŸ’¬︎
πŸ‘€︎ u/entertainer011
πŸ“…︎ May 09 2021
🚨︎ report
Dis-a-
πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/krismoff
πŸ“…︎ May 06 2021
🚨︎ report
Such a pointless conversation.
πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/david_pridson
πŸ“…︎ May 16 2021
🚨︎ report
What is the fastest growing city in the world?

Capital of Ireland

It's Dublin everyday

πŸ‘︎ 9k
πŸ’¬︎
πŸ‘€︎ u/PeaPanties
πŸ“…︎ May 16 2021
🚨︎ report
Don't know if this was posted here before
πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/choclite69
πŸ“…︎ May 10 2021
🚨︎ report
Peace Walker was severely under rated IMO.

Granted.... It is likely just because it was originally a portable exclusive, and not that many people play portable games.

Man... I really loved Peace Walker. IIRC it is the only game with cooperative multiplayer, which was amazing because my brother lived overseas and I LOVED playing this with him every day. However unlike some other games who struggle to strike a balance between multiplayer and single player, Peace Walker managed to do it really well to where there wasn’t too extreme of an advantage in playing with 4 people. I mean it was waaaay easier to get spotted with 4 jackasses running around and the bosses were very well programmed to where they used more of their weaponry when multiple targets are present (For example, the Cocoon won’t just fire off its entire arsenal against a single player and will usually use 1 or 2 weapons at a time, however with more players, it will multitask as use more and more of its weapons at once).

Oh yeah, the boss fights.. They were amazing. I think this game had the most boss battles of any MGS title aside from maaaaaybe MHR:R. And the fights were usually quite fun... Though honestly I got sick of the 500th tank and APC bosses. The AI battles were the HIGHLIGHT of some of the best battles in the series. I fucking LOVED fighting these guys. One aspect I loved in particular was how many ways you could fight them, there was no β€œone way” to beat them, there were several ways and each way gave you different rewards for constructing ZEKE (oh yeah, you can make your own fucking Metal Gear!). Take fighting Pupa, you had the option to solely go after its AI pod for a quicker kill and more chips with the draw back of having a harder fight OR you could choose to blast apart its components and weaken it to get its parts at the cost of a longer battle.

The story was really cool too. I admit message wise it wasn’t as deep or complex as in MGS2 or MGS3, but I still found the idea of the Peace Walker machine to be interesting, with it being guaranteed to retaliate against a nation’s nuclear attack because of Hot Coldman’s (I bet Kojima feels real proud about this name) hypothesizes that humans are naturally hesitant to retaliate and kill millions of people. I did think the whole β€œPeace Walker is the Boss” plot thing was kinda silly admittedly, I mean I guess it’s kinda tame in a series composed of psychics, super powered plant girls, giant ass mechs and 4th wall breaks, but it still felt kinda dumb and I don’t really understa

... keep reading on reddit ➑

πŸ‘︎ 54
πŸ’¬︎
πŸ‘€︎ u/InsertUsername98
πŸ“…︎ Mar 28 2021
🚨︎ report
Did you know that 10+10 and 11+11 are the same thing?

Because 10+10 is twenty and 11+11 is twenty too..

Edit: thank you for awards, I have never gotten one before. I apologize that this is a repost, I did see it on TikTok and thought that it was cute and wanted to share. In the future I will check the sub for similar content before I post anything.

πŸ‘︎ 8k
πŸ’¬︎
πŸ‘€︎ u/Lewzerman
πŸ“…︎ May 18 2021
🚨︎ report
What the fuck has happened to this sub!?

http://m.imgur.com/ImM3RWz

πŸ‘︎ 8k
πŸ’¬︎
πŸ‘€︎ u/FwootHotCaacon
πŸ“…︎ May 16 2021
🚨︎ report
Bill and Melinda Gates got divorced. Melinda got the house...

But Bill kept the Windows

πŸ‘︎ 12k
πŸ’¬︎
πŸ‘€︎ u/ScubaPride
πŸ“…︎ May 05 2021
🚨︎ report
The Communist ....Party
πŸ‘︎ 3k
πŸ’¬︎
πŸ‘€︎ u/Saxonez
πŸ“…︎ May 18 2021
🚨︎ report
From my 5-year-old son: "Hey"

True story; it even happened last night. My 5-year-old son walks up behind me and out of the blue says, "hey."

I turn to him and say, "yeah, kiddo? What's up?"

He responds, "it's dead grass."

I'm really confused and trying to figure out what's wrong and what he wants from me. "What? There's dead grass? What's wrong with that?"

.

.

.

He says, totally straight-faced, "hay is dead grass," and runs off.

πŸ‘︎ 13k
πŸ’¬︎
πŸ“…︎ May 10 2021
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.