lock vs ReadWriteLockSlim vs Fiber vs? [Question]
Options
What are differences between these functions(and maybe is there more?) and in which situations I should use them?
For example, I did Sheldude by Fiber and in this Sheldude, I change list I need to lock it or just use fiber.Enqueue?
And If I change list in another function (not by fiber schedule) I use lock, readerwritelock slim or Enqueue?
For example, I did Sheldude by Fiber and in this Sheldude, I change list I need to lock it or just use fiber.Enqueue?
And If I change list in another function (not by fiber schedule) I use lock, readerwritelock slim or Enqueue?
0
Comments
-
Fiber is queue of tasks which might be exeucted on different threads but in strict order. so if you enqueue action1 and then action2 to fiber, action1 will be executed first, action2 will be executed next. and it could be that they will be executed on different ThreadPool threads
because tasks exeucted in strict order everything what you do in one fiber does NOT require locking. if two or more fibers access to same data then you need locking.
theory behind locking is out of scope of this forum. please use google
best,
ilya0 -
For Fiber block actions I need write fiber.Enqueue{} right? (I'm using Fiber.ScheldudeOnInterval)0
-
it depends on what you want to get. fiber.Enqueue for one time actions, Schedule for scheduled actionis, ScheduleOnInterval for actions which should be repeated. but anyway fiber executes one operation at once
best,
ilya0