https://github.com/mark24code/rb_simulate_eventloop
use Ruby mock eventloop
https://github.com/mark24code/rb_simulate_eventloop
Last synced: 11 months ago
JSON representation
use Ruby mock eventloop
- Host: GitHub
- URL: https://github.com/mark24code/rb_simulate_eventloop
- Owner: Mark24Code
- License: bsd-2-clause
- Created: 2022-08-11T09:46:48.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-11T10:56:59.000Z (over 3 years ago)
- Last Synced: 2025-01-24T01:08:21.341Z (about 1 year ago)
- Language: Ruby
- Size: 555 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ruby code simulate Eventloop
## Run sample
use Ruby code simulate Eventloop
`ruby sample.rb`
`node sample.js`
compare the result
## Simulate Features
simulate eventloop
* macro_task
* micro_task
* settimeout ( timer micro_task)
* promise (micro_task)
## Eventloop Model
```
(start)
|
init (e.g create TimerThread )
|
sync task (e.g read & run code)
|
|
------------------>
| | -------------
| macro_task --- add timer task --> | TimerThread |
| (Eventloop) | <-- insertjob result --- -------------
| |
| micro_task
| |
| |
<-----------------
|
|
(end)
```
## Sample Result
