Object Isolation
-
Hi there, This query is with respect to the isolation of object in a collection. And like to hear couple of approaches those are feasible in such scenario. First, let me explain the problem which I am facing at this time. Our application has few rules (objects in concize) associated with few entities, those are editable for all currently active users (U1, U2). Assume that, we have 2 rules (R1, R2). Our requirement is no two users can edit, delete or modify a specific rule at same point of time. Eg: If U1 update R1 then U2 has to wait till U1 release R1. If U1 update R2 then U2 have provision to update R1 since R1 is not locked by any user. I hope you are clear about the requirement. Now, to ensure the above discussed functionality we implemented a method which uses Interlocked Class in threading namespace (VS.NET & C#). This approach in fact helps us while avoiding concurrent user access over a specific instance on a specific time using some flag value. But the problem is, it locks the entire rule collection (R1, R2) even thou there is no concurrent user. I presume, this is because of the way we model the class and is a collection (rule collection). Eg: If I have N rules in rule collection, it doesn’t mean that I need to lock all N rule objects in the rule collection. But I only need to lock specific rule (subset of rule collection), those are currently used by some logged users. And ensure all other non affected rules are free from lock. I did have a thought on the object level locking using .Net object locking mechanisms. But this is practically impossible to implement locking mechanism for each and every functionality. FYI: It is small product which has 54 projects (30 services, test projects, script) in C#.NET. And the product has its 70% of functionalities in place. So a major rework in object level is not practical at this moment since it has to go through lot of review and regression process. I hope you are clear with respect to the problem statement. Can you explain me which method would be feasible in such scenario ? How will i make sure only the object lock is available for the object which is currently i use and not other objects in the collection? And how will I ensure object level isolation than locking an entire collection? Do we have any proved patterns for this kind of problems? Thanks in advance. ;)
-
Hi there, This query is with respect to the isolation of object in a collection. And like to hear couple of approaches those are feasible in such scenario. First, let me explain the problem which I am facing at this time. Our application has few rules (objects in concize) associated with few entities, those are editable for all currently active users (U1, U2). Assume that, we have 2 rules (R1, R2). Our requirement is no two users can edit, delete or modify a specific rule at same point of time. Eg: If U1 update R1 then U2 has to wait till U1 release R1. If U1 update R2 then U2 have provision to update R1 since R1 is not locked by any user. I hope you are clear about the requirement. Now, to ensure the above discussed functionality we implemented a method which uses Interlocked Class in threading namespace (VS.NET & C#). This approach in fact helps us while avoiding concurrent user access over a specific instance on a specific time using some flag value. But the problem is, it locks the entire rule collection (R1, R2) even thou there is no concurrent user. I presume, this is because of the way we model the class and is a collection (rule collection). Eg: If I have N rules in rule collection, it doesn’t mean that I need to lock all N rule objects in the rule collection. But I only need to lock specific rule (subset of rule collection), those are currently used by some logged users. And ensure all other non affected rules are free from lock. I did have a thought on the object level locking using .Net object locking mechanisms. But this is practically impossible to implement locking mechanism for each and every functionality. FYI: It is small product which has 54 projects (30 services, test projects, script) in C#.NET. And the product has its 70% of functionalities in place. So a major rework in object level is not practical at this moment since it has to go through lot of review and regression process. I hope you are clear with respect to the problem statement. Can you explain me which method would be feasible in such scenario ? How will i make sure only the object lock is available for the object which is currently i use and not other objects in the collection? And how will I ensure object level isolation than locking an entire collection? Do we have any proved patterns for this kind of problems? Thanks in advance. ;)
-
It's too late to do a design change and looking forward for a wrapper kind of approach or attribute. Anyway thanks for your reply. :)