55
edits
m (→Thread safety) |
|||
| Line 48: | Line 48: | ||
Since strings are immutable, they are by definition thread safe. The only unsafe operation if the flattening operation. Therefore, the <tt>flatten()</tt> should look like this: | Since strings are immutable, they are by definition thread safe. The only unsafe operation if the flattening operation. Therefore, the <tt>flatten()</tt> should look like this: | ||
void String::flatten() { | void String::flatten() { | ||
if (0 != this | if (0 != this->treeLevel) { | ||
ENTER_CRITICAL_SECTION; | ENTER_CRITICAL_SECTION; | ||
if (0 != treeLevel) { | if (0 != this->treeLevel) { | ||
// do the magic | // do the magic | ||
} | } | ||
edits