-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #451 from JetBrains/backend-listeners-support-usov
Backend listeners support
- Loading branch information
Showing
14 changed files
with
183 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
rd-kt/rd-framework/src/main/kotlin/com/jetbrains/rd/framework/RdEntitiesRegistrar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.jetbrains.rd.framework | ||
|
||
import com.jetbrains.rd.util.ConcurrentHashMap | ||
import com.jetbrains.rd.util.addUnique | ||
import com.jetbrains.rd.util.lifetime.Lifetime | ||
|
||
class RdEntitiesRegistrar { | ||
private val map = ConcurrentHashMap<RdId, IRdDynamic>() | ||
|
||
internal fun register(lifetime: Lifetime, rdId: RdId, dynamic: IRdDynamic) { | ||
require(!rdId.isNull) | ||
map.addUnique(lifetime, rdId, dynamic) | ||
} | ||
|
||
fun tryGetDynamic(rdId: RdId): IRdDynamic? = map[rdId] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Collections.Generic; | ||
using JetBrains.Diagnostics; | ||
using JetBrains.Lifetimes; | ||
using JetBrains.Rd.Base; | ||
using JetBrains.Rd.Util; | ||
|
||
namespace JetBrains.Rd.Impl; | ||
|
||
public class RdEntitiesRegistrar | ||
{ | ||
private readonly Dictionary<RdId, IRdDynamic> myMap = new(); | ||
|
||
internal void Register(Lifetime lifetime, RdId rdId, IRdDynamic dynamic) | ||
{ | ||
Assertion.Assert(!rdId.IsNil); | ||
|
||
myMap.BlockingAddUnique(lifetime, myMap, rdId, dynamic); | ||
} | ||
|
||
public bool TryGetEntity(RdId rdId, out IRdDynamic entity) | ||
{ | ||
lock (myMap) | ||
{ | ||
return myMap.TryGetValue(rdId, out entity); | ||
} | ||
} | ||
} |
Oops, something went wrong.