<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Feb 27, 2014, at 8:00 AM, Argyrios Kyrtzidis <<a href="mailto:kyrtzidis@apple.com">kyrtzidis@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class="Apple-interchange-newline">On Feb 27, 2014, at 4:43 AM, Manuel Klimek <<a href="mailto:klimek@google.com">klimek@google.com</a>> wrote:</div><br class="Apple-interchange-newline" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Feb 27, 2014 at 1:37 PM, Manuel Klimek<span class="Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On Wed, Feb 12, 2014 at 11:22 PM, Douglas Gregor<span class="Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:dgregor@apple.com" target="_blank">dgregor@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto;"><div><br>On Feb 12, 2014, at 2:21 PM, Rafael Ávila de Espíndola <<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>> wrote:<br><br>><br>><br>> ================<br>> Comment at: include/clang/Basic/FileManager.h:122<br>> @@ -121,2 +121,3 @@<br>> class FileManager : public RefCountedBase<FileManager> {<br>> +  IntrusiveRefCntPtr<AbstractFileSystem> FS;<br>>   FileSystemOptions FileSystemOpts;<br>> ----------------<br>> Why is the reference count necessary? Given its nature I would expect the FS to outlive the file manger, in which case the FileManager could have just a pointer to the FileSystem.<br><br><br></div>The FS is likely to get shared among a number of FileManagers in different compiler instances within a thread. Yes, we could try to establish and maintain relationships among these, but it’s simpler and costs us effectively nothing to make this ref-counted.<br></blockquote><div><br></div></div></div><div>Just to follow up:</div><div>I found one more argument against making this ref-counted:</div><div>The constructor of FileManager that uses the default "real" file system is now actively thread hostile (you cannot create a FileManager per thread without locking). I think that's rather unexpected.</div></div></div></div></blockquote><div><br></div><div>And even worse, because RealFileSystem is an implementation detail, and getRealFileSystem returns a ref counted pointer by value, I cannot see any way to get me a RealFileSystem without locking.</div><div><br></div></div></div></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">I propose we introduce a RefCountedBase that is using atomic reference count (either change RefCountedBase or add a new class), and have FileSystem use that.</div><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></blockquote><div><br></div><div>Makes sense to me.  Manuel, does this address your concern?</div><div><br></div><div>Ben</div><br><blockquote type="cite"><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Cheers,</div><div>/Manuel</div></div></div></div></blockquote></blockquote></div><br></body></html>