[prev in list] [next in list] [prev in thread] [next in thread] 

List:       taglib-devel
Subject:    Re: iterators+multithreading on win32
From:       "Stephen F. Booth" <me () sbooth ! org>
Date:       2011-03-05 23:11:56
Message-ID: AANLkTinriu-MZ9N6p2RxrJJ37HWYttbT6dzzwNTRdCKu () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I'm not familiar with atomic operations on Windows or Linux, but I've
attached my first stab at a patch that makes RefCounter use atomic increment
and decrement operations on OS X.

I doubt this will take care of everything, but it should be a start.

Stephen

On Sat, Mar 5, 2011 at 2:36 PM, Michael Pyne <mpyne@purinchu.net> wrote:

> On Saturday, March 05, 2011 13:21:21 James O. wrote:
> > Correct me if I'm wrong, but since hard drives can't read from two places
> at
> > once are speed increases actually realized from trying to multithread
> reads
> > with TagLib?
>
> Well, hard disks might surprise you (there are multiple physical platters
> typically, there's no theoretical reason it couldn't support streaming
> multiple files over a bus with a large enough transfer rate).
>
> In addition it is very easy for the OS and hard disk both to perform read-
> ahead and essentially read and return 3 files at a time (if they're laid
> out
> on the disk properly).
>
> It's the kind of thing you'd actually want to profile if at all possible
> before assuming that there would be no change.
>
> Regards,
>  - Michael Pyne
> _______________________________________________
> taglib-devel mailing list
> taglib-devel@kde.org
> https://mail.kde.org/mailman/listinfo/taglib-devel
>
>

[Attachment #5 (text/html)]

I&#39;m not familiar with atomic operations on Windows or Linux, but I&#39;ve \
attached my first stab at a patch that makes RefCounter use atomic increment and \
decrement operations on OS X.<div><br></div><div>I doubt this will take care of \
everything, but it should be a start.</div> <div><br></div><div>Stephen<br><br><div \
class="gmail_quote">On Sat, Mar 5, 2011 at 2:36 PM, Michael Pyne <span \
dir="ltr">&lt;<a href="mailto:mpyne@purinchu.net">mpyne@purinchu.net</a>&gt;</span> \
wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex;"> <div class="im">On Saturday, March 05, 2011 13:21:21 \
James O. wrote:<br> &gt; Correct me if I&#39;m wrong, but since hard drives can&#39;t \
read from two places at<br> &gt; once are speed increases actually realized from \
trying to multithread reads<br> &gt; with TagLib?<br>
<br>
</div>Well, hard disks might surprise you (there are multiple physical platters<br>
typically, there&#39;s no theoretical reason it couldn&#39;t support streaming<br>
multiple files over a bus with a large enough transfer rate).<br>
<br>
In addition it is very easy for the OS and hard disk both to perform read-<br>
ahead and essentially read and return 3 files at a time (if they&#39;re laid out<br>
on the disk properly).<br>
<br>
It&#39;s the kind of thing you&#39;d actually want to profile if at all possible<br>
before assuming that there would be no change.<br>
<br>
Regards,<br>
<font color="#888888"> - Michael \
Pyne</font><br>_______________________________________________<br> taglib-devel \
mailing list<br> <a href="mailto:taglib-devel@kde.org">taglib-devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/taglib-devel" \
target="_blank">https://mail.kde.org/mailman/listinfo/taglib-devel</a><br> \
<br></blockquote></div><br></div>

--001636b14adb995940049dc4639c--


["atomics_osx.diff" (application/octet-stream)]

Index: taglib.h
===================================================================
--- taglib.h	(revision 1223897)
+++ taglib.h	(working copy)
@@ -42,6 +42,10 @@
 #define TAGLIB_CONSTRUCT_BITSET(x) static_cast<unsigned long>(x)
 #endif
 
+#ifdef __APPLE__
+# include <libkern/OSAtomic.h>
+#endif
+
 #include <string>
 
 //! A namespace for all TagLib related classes and functions
@@ -81,11 +85,21 @@
   {
   public:
     RefCounter() : refCount(1) {}
+#ifdef __APPLE__
+    void ref() { OSAtomicIncrement32(&refCount); }
+    bool deref() { return ! OSAtomicDecrement32(&refCount); }
+    int32_t count() { return refCount; }
+#else
     void ref() { refCount++; }
     bool deref() { return ! --refCount ; }
     int count() { return refCount; }
+#endif
   private:
+#ifdef __APPLE__
+    volatile int32_t refCount;
+#else
     uint refCount;
+#endif
   };
 
 #endif // DO_NOT_DOCUMENT


_______________________________________________
taglib-devel mailing list
taglib-devel@kde.org
https://mail.kde.org/mailman/listinfo/taglib-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic