Fiber (Part 4)
kishore.app·6d
🚀Web Performance
Preview
Report Post

Part 3 (Fiber interruption and Lifecycle hooks) is

A resource is anything that needs to be acquired, and need to released after usage. We cannot keep it open forever, since that would lead to resource leaks. A resource can be anything. Like a database connection, a file handle, a network socket, etc.

Managing Resources in Fibers

Below is a pseudo code we use to simulate a resource in the examples below:

We only simulate acuiring and releasing the resource with some delays. But we don’t care about what the resource actually is for this discussion.


Let’s say we want to use a resource (database connection, websocket connection, file handle, etc.) in a fiber. Where we open the resource, use it, and then close back the resource when fiber completes.

Aquiring already e…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help