08.11.2014 Views

Memory Management - Poco

Memory Management - Poco

Memory Management - Poco

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

#include "<strong>Poco</strong>/AutoPtr.h"<br />

using <strong>Poco</strong>::AutoPtr;<br />

class RCO<br />

{<br />

public:<br />

RCO(): _rc(1)<br />

{<br />

}<br />

void duplicate()<br />

{<br />

++_rc; // Warning: not thread safe!<br />

}<br />

void release()<br />

{<br />

if (--_rc == 0) delete this; // Warning: not thread safe!<br />

}<br />

private:<br />

int _rc;<br />

};

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!