On Monday, 14 November 2022 at 07:57:16 UTC, Kagamin wrote:
This works for me:
```
shared SyncAA!(string,string) saa;
void f()
{
saa=new shared SyncAA!(string,string)("1","2");
saa.keys();
saa["12"]="34";
saa.remove("12");
}
```
The strange error message I got
This works for me:
```
synchronized final class SyncAA(K, V)
{
this(K key, V val) { sharedTable[key]=val; }
V opIndex(K key) { return sharedTable[key]; }
V opIndexAssign(V value, K key) { return sharedTable[key]=value;
}
const(K[]) keys() const { return
On Friday, 11 November 2022 at 14:19:31 UTC, Kagamin wrote:
Try this:
```
private:
V[K] sharedTable;
ref inout(V[K]) unsharedTable() inout
{
return *cast(inout(V[K])*)
}
```
Thanks, that worked! Feels like programming in C, though. If I
could
With allocation:
```
synchronized final class SyncAA(K, V)
{
V opIndex(K key) { return sharedTable[key]; }
V opIndexAssign(V value, K key) { return sharedTable[key]=value;
}
const(K[]) keys() const { return unsharedTable.keys; }
void remove(K key) {
Try this:
```
synchronized final class SyncAA(K, V)
{
V opIndex(K key) { return sharedTable[key]; }
V opIndexAssign(V value, K key) { return sharedTable[key]=value;
}
const(K[]) keys() const { return unsharedTable.keys; }
void remove(K key) { sharedTable.remove(key); }
On Friday, 11 November 2022 at 01:09:54 UTC, torhu wrote:
On Thursday, 10 November 2022 at 21:55:26 UTC, torhu wrote:
I'm trying to make a more thread-safe wrapper for AA's:
```
synchronized final class SyncAA(K, V) ///
I chose to fix this by just using `synchronized (this)` inside
each
On Thursday, 10 November 2022 at 21:55:26 UTC, torhu wrote:
I'm trying to make a more thread-safe wrapper for AA's:
```
synchronized final class SyncAA(K, V) ///
I chose to fix this by just using `synchronized (this)` inside
each method instead, for now. Still interested in cleaner