C
C#11mo ago
LPeter1997

❔ Concurrent-exclusive scheduling with prioritizing exclusive execution

First off: I'm aware of ConcurrentExclusiveSchedulerPair from TPL, sadly it's not applicable for us, because it doesn't have the scheduling behavior we need. We have a bunch of messages coming in a sequential channel, that we are processing. Some messages are marked as EXCLUSIVE, some are not. EXCLUSIVE messages must be processed exclusively, as in no other message processing can be done in parallel. If there are only non-exclusive messages to process, the processing of those can happen in parallel. Whenever an exclusive message comes in, no further messages can be processed (except the ones that are already started), this means that if a non-exclusive message slips in after, the processing of that can not be started (this is the major behavior difference we need from ConcurrentExclusiveSchedulerPair). Anyone knows of such a scheduler/mechanism implementation somewhere? I'm not too well-versed with parallel/scheduling code so if I don't have to, I wouldn't spend ages trying to make an efficient and decent impl for it.
6 Replies
Azrael
Azrael11mo ago
lock statement - synchronize thread access to a shared resource
Use the C# lock statement to ensure that only a single thread exclusively reads or writes a shared resource, blocking all other threads until it completes.
Azrael
Azrael11mo ago
"Whenever an exclusive message comes in, no further messages can be processed", use a lock and a list to store all the non-exclusive ones.
LPeter1997
LPeter199711mo ago
Uhh... I'll wait for TPL experts to answer 😅
Azrael
Azrael11mo ago
👍
Accord
Accord11mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.