@@ -110,12 +110,16 @@ struct dictAsyncRehashCtl {
110110 std::atomic<bool > abondon { false };
111111
112112 dictAsyncRehashCtl (struct dict *d, dictAsyncRehashCtl *next);
113+ dictAsyncRehashCtl (const dictAsyncRehashCtl&) = delete ;
114+ dictAsyncRehashCtl (dictAsyncRehashCtl&&) = delete ;
113115 ~dictAsyncRehashCtl ();
114116};
115117#else
116118struct dictAsyncRehashCtl ;
117119#endif
118120
121+ void discontinueAsyncRehash (dict *d);
122+
119123typedef struct dict {
120124 dictType *type;
121125 void *privdata;
@@ -125,6 +129,24 @@ typedef struct dict {
125129 dictAsyncRehashCtl *asyncdata;
126130 int16_t pauserehash; /* If >0 rehashing is paused (<0 indicates coding error) */
127131 uint8_t noshrink = false ;
132+
133+ #ifdef __cplusplus
134+ dict () = default;
135+ dict (dict &) = delete; // No Copy Ctor
136+
137+ static void swap (dict& a, dict& b) {
138+ discontinueAsyncRehash (&a);
139+ discontinueAsyncRehash (&b);
140+ std::swap (a.type , b.type );
141+ std::swap (a.privdata , b.privdata );
142+ std::swap (a.ht [0 ], b.ht [0 ]);
143+ std::swap (a.ht [1 ], b.ht [1 ]);
144+ std::swap (a.rehashidx , b.rehashidx );
145+ // Never swap refcount - they are attached to the specific dict obj
146+ std::swap (a.pauserehash , b.pauserehash );
147+ std::swap (a.noshrink , b.noshrink );
148+ }
149+ #endif
128150} dict;
129151
130152/* If safe is set to 1 this is a safe iterator, that means, you can call
0 commit comments