1.linux find export

find /Applications/Xcode.app/ -name symbolicatecrash -type f

export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"

2.symbolicatecrash

http://www.cnblogs.com/ningxu-ios/p/4141783.html

3.AURenderCallbackStruct

        AURenderCallbackStruct callbackStruct;
callbackStruct.inputProc = AudioPlayUnit_context::playbackCallback;
callbackStruct.inputProcRefCon = this;

4.生产者-消费者

1)缓冲区,缓冲区写满需等待,消费者消费后需通知

class BytesBuffer : public IceUtil::Shared
{
public:
BytesBuffer(size_t bufferSize);
void feed(size_t size, BufferChunkRef cbChunk);
void eat(size_t size, BufferChunkRef cbChunk);

等待

void BytesBuffer_context::feed(size_t size, BufferChunkRef cbChunk)
{
{
Monitor<RecMutex>::Lock lock(_monitor);
if (_feedTerminated) return; while( size > _feedCapacity && !_eatTerminated) {
_currentFeedRequestSize = size;
// SP::printf("\nwait feeding, eatting %s\n", _eatTerminated ? "terminated" : "not terminated");
_monitor.wait();
}
_currentFeedRequestSize = ;
}

通知

        Monitor<RecMutex>::Lock lock(_monitor);
//check and notify, if _feedTerminated then _currentFeedRequestSize=0, verify already included
if (_feedCapacity < _currentFeedRequestSize && _feedCapacity + size >= _currentFeedRequestSize)
_monitor.notify();

  

2)生产者

DecoderFileThread::DecoderFileThread(const char* path, BytesBufferPtr buffer)
: filepath(path)
, _buffer(buffer)
, _destroy(false)
, _decodeState() , file()
{
_cbChunk._userData = this;
_cbChunk._callback = DecoderFileThread::feedCallback;
} void DecoderFileThread::run()
{
_decodeState = Decoder_Interface_init();
file = fopen(filepath.c_str(), "rb");
fseek(file, , );
do {
_buffer->feed(*, &_cbChunk);
} while (!_destroy);
Decoder_Interface_exit(_decodeState);
fclose(file);
//SP::printf("\nfinish decode file\n");
}

3)消费者

OSStatus AudioPlayUnit_context::playbackCallback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData) {
#if !TEST
// Notes: ioData contains buffers (may be more than one!)
// Fill them up as much as you can. Remember to set the size value in each buffer to match how
// much data is in the buffer.
AudioPlayUnit_context* This = (AudioPlayUnit_context*)inRefCon; RenderChunk cbchunk = {};
cbchunk.inRefCon = This;
cbchunk.ioActionFlags = ioActionFlags;
cbchunk.inTimeStamp = inTimeStamp;
cbchunk.inBusNumber = inBusNumber;
cbchunk.inNumberFrames = inNumberFrames;
cbchunk.ioData = ioData; BufferChunk chunk;
chunk._callback = AudioPlayUnit_context::eatCallback;
chunk._userData = &cbchunk;
This->_buffer->eat(inNumberFrames*This->_audioFormat.mBytesPerFrame, &chunk); static size_t expired = ;
static IceUtil::Time lasttime;
if(This->_renderstartTimestamp == )
{
This->_renderstartTimestamp = IceUtil::Time::now().toMilliSeconds();
expired = ;
}
else
expired = IceUtil::Time::now().toMilliSeconds() - This->_renderstartTimestamp; if (This->_listenerPtr.get()) This->_listenerPtr->progress(This->_listenerPtr->userData, expired);
return noErr;
#else AudioPlayUnit_context* This = (AudioPlayUnit_context*)inRefCon;
static size_t pos = ;
ioData->mBuffers[].mData = This->_filebuffer + pos;
pos += inNumberFrames*;
//bytes2HexS((unsigned char*)ioData->mBuffers[0].mData, inNumberFrames*2);
return noErr;
#endif
}

5.ice

unix网络编程(卷2)7.3小节描述了生产者-消费者问题,7.5小节描述了条件变量

iceutil的monitor就是cpp的封装实现。

//
// This monitor implements the Mesa monitor semantics. That is any
// calls to notify() or notifyAll() are delayed until the monitor is
// unlocked.
//
template <class T>
class Monitor
{

6.引用计数

objective-c的引用计数很好理解,[[xx alloc] init]引用计数为1,retain引用计数加1,release引用计数减1,当引用计数为0时销毁内存。

ice的IceUtil::Shared包含了引用计数加1减1,但IceUtil::Shared在构造函数和析构函数并不会改变引用计数。使用时是使用IceUtil::Handle对象,IceUtil::Handle包含一个_ptr,构造函数如果参数为空,_prt置为null。如果构造函数的参数不为空,就会将_prt的引用计数加1,this->_ptr->__incRef(),析构函数会将_ptr的引用计数减1,this->_ptr->__decRef()。decRef函数判断引用计数为0时销毁内存。

IceUtril::Handle的拷贝构造函数和赋值函数也是将_ptr引用计数加1.因此有多个IceHandle包含同一个IceUtil::Shared,将IceUtil::Shared的引用计数加加减减。

IceUtil::Shared是用户自己new出来的,默认的引用计数为0,使用IceUtil::Handle时才会改变_ptr引用计数的值。

ace的ACE_Refcounted_Auto_Ptr_Rep包含了引用计数,内部包括一个auto_ptr的ptr_对象,构造函数会创建ptr_对象,析构时ptr_对象也会自动销毁,auto_ptr对象销毁时会释放new出来的内存。通过static函数attach,detach将引用计数加1减1,detach函数判断引用计数为0时销毁ACE_Refcounted_Auto_Ptr_Rep对象。

ace使用时是使用 ACE_Refcounted_Auto_Ptr,ACE_Refcounted_Auto_Ptr对象构造函数会创建ACE_Refcounted_Auto_Ptr_Rep对象rep_,析构函数会调用detach函数将rep_的引用计数减1.ACE_Refcounted_Auto_Ptr对象的拷贝构造函数和赋值函数也是将rep_引用计数加1.

因此有多个ACE_Refcounted_Auto_Ptr包含同一个ACE_Refcounted_Auto_Ptr_Rep,将ACE_Refcounted_Auto_Ptr_Rep的引用计数加加减减。

ACE_Refcounted_Auto_Ptr_Rep对象是ACE_Refcounted_Auto_Ptr对象构造函数创建的。使用ACE_Refcounted_Auto_Ptr时会改变rep_引用计数的值。

总结:

ace的ACE_Refcounted_Auto_Ptr不是很好理解,因为X *p并没有引用计数,所以需要封装一个ACE_Refcounted_Auto_Ptr_Rep对象,但ACE_Refcounted_Auto_Ptr_Rep对象又不是用户自己创建的,是构造函数自己创建的。 而构造函数中又没有通过ACE_Refcounted_Auto_Ptr_Rep对象来创建,这样就隐藏了ACE_Refcounted_Auto_Ptr_Rep对象的存在,让人不好理解。

第一步,创建ACE_Refcounted_Auto_Ptr_Rep对象,第二步使用ACE_Refcounted_Auto_Ptr。ace不让用户一步步完成。构造函数是通过X *p创建ACE_Refcounted_Auto_Ptr_Rep对象,拷贝构造函数和赋值函数是通过const ACE_Refcounted_Auto_Ptr<X, ACE_LOCK> &r的rep_引用计数加1。

而ice 因此如果需要将一个对象申明智能指针,必须让其继承至IceUtil::Shared,就好理解一点。

iceutil::Shared

class ICE_UTIL_API Shared
{
public: Shared();
Shared(const Shared&); virtual ~Shared()
{
} Shared& operator=(const Shared&)
{
return *this;
} virtual void __incRef();
virtual void __decRef();
virtual int __getRef() const;
virtual void __setNoDelete(bool); protected: #if defined(_WIN32)
LONG _ref;
#elif defined(ICE_HAS_ATOMIC_FUNCTIONS) || defined(ICE_HAS_GCC_BUILTINS)
volatile int _ref;
#else
int _ref;
Mutex _mutex;
#endif
bool _noDelete;
}; }

ace

template <class X, class ACE_LOCK> inline
ACE_Refcounted_Auto_Ptr<X, ACE_LOCK>::ACE_Refcounted_Auto_Ptr (X *p)
: rep_ (AUTO_REFCOUNTED_PTR_REP::create (p))
{
} template <class X, class ACE_LOCK> inline
ACE_Refcounted_Auto_Ptr<X, ACE_LOCK>::ACE_Refcounted_Auto_Ptr (const ACE_Refcounted_Auto_Ptr<X, ACE_LOCK> &r)
: rep_ (AUTO_REFCOUNTED_PTR_REP::attach (((ACE_Refcounted_Auto_Ptr<X, ACE_LOCK> &) r).rep_))
{
} template <class X, class ACE_LOCK> inline void
ACE_Refcounted_Auto_Ptr<X, ACE_LOCK>::operator = (const ACE_Refcounted_Auto_Ptr<X, ACE_LOCK> &rhs)
{
// bind <this> to the same <ACE_Refcounted_Auto_Ptr_Rep> as <r>.
AUTO_REFCOUNTED_PTR_REP *old_rep = this->rep_;
if (rhs.rep_ != )
{
this->rep_ = AUTO_REFCOUNTED_PTR_REP::attach
(const_cast<ACE_Refcounted_Auto_Ptr<X, ACE_LOCK>& > (rhs).rep_);
if (this->rep_ != )
AUTO_REFCOUNTED_PTR_REP::detach (old_rep);
}
else // Assign a 0 rep to this
{
AUTO_REFCOUNTED_PTR_REP::detach (old_rep);
this->rep_ = ;
}
} template <class X, class ACE_LOCK>
ACE_Refcounted_Auto_Ptr<X, ACE_LOCK>::~ACE_Refcounted_Auto_Ptr (void)
{
AUTO_REFCOUNTED_PTR_REP::detach (rep_);
}

7.书籍

http://bestcbooks.com/recommended-cpp-books/

第3月第2天 find symbolicatecrash 生产者-消费者 ice 引用计数的更多相关文章

  1. 2017年5月11日17:43:06 rabbitmq 消费者队列

    从昨天开始发现个问题,一个接口在本地调用时大部分正常,一旦在生成者打一个断点调试,并且在promotion也打断点的时候会出现没有返回channel的异常,然后消费者就再也消费不了了 16:57:45 ...

  2. 4月25日 python学习总结 互斥锁 IPC通信 和 生产者消费者模型

    一.守护进程 import random import time from multiprocessing import Process def task(): print('name: egon') ...

  3. 第21月第4天 leetcode codinginterview c++

    1.leetcode Implement strStr(). Returns the index of the first occurrence of needle in haystack, or - ...

  4. 半个月使用rust语言的体验

    从第一次下载rust语言的编译器到今天刚好第14天. 简单说一下对这个语言的感觉吧. 一.性能 把以前用java写的一个中文地址切分的算法,用rust重新实现了一下(https://github.co ...

  5. 本周MySQL官方verified/open的bug列表(11月8日至11月14日)

    本周MySQL verified的bug列表(11月8日至11月14日) 1. Bug #70859-DWITH_EXAMPLE_STORAGE_ENGINE=1 is ignored     URL ...

  6. java_面试_01_一个月的面试总结(java)

    重点知识 由于我面试的JAVA开发工程师,针对于JAVA,需要理解的重点内容有: JVM内存管理机制和垃圾回收机制(基本每次面试都会问,一定要搞得透彻) JVM内存调优(了解是怎么回事,一般做项目过程 ...

  7. Android SDK 与API版本对应关系

    Android SDK版本号 与 API Level 对应关系如下表: Code name Version API level   (no code name) 1.0 API level 1   ( ...

  8. Linux基础介绍【第四篇】

    Linux文件和目录的属性及权限 命令: [root@oldboy ~]# ls -lhi total 40K 24973 -rw-------. 1 root root 1.1K Dec 10 16 ...

  9. 转职成为TypeScript程序员的参考手册

    写在前面 作者并没有任何可以作为背书的履历来证明自己写作这份手册的分量. 其内容大都来自于TypeScript官方资料或者搜索引擎获得,期间掺杂少量作者的私见,并会标明. 大部分内容来自于http:/ ...

随机推荐

  1. mysql表复制和修改部分字段

    今天在工作中,需要造大量的加数据,1000多条数据如果都是手工输入的话,那么我今天不要干别的了,就造吧! 当时手工操作重复的事情,对程序员来说,是一件很丢人的事情,所以就上网查了一下,需要用到两个知识 ...

  2. GNU make使用变量⑤变量的引用、定义等

    在 Makefile 中,变量是一个名字(像是 C 语言中的宏),代表一个文本字符串(变量的值).在 Makefile 的目标.依赖.命令中引用变量的地方,变量会被它的值所取代(与 C 语言中宏引用的 ...

  3. 脑成像数据分析:Python工具包

    来源:SealHuang 脑成像技术已经成为认知科学和心理学研究领域中一种重要的研究手段,帮助研究者不断深入发掘我们脑中的秘密.伴随着研究的不断深入,各式各样的指标参数和分析方法也不断推陈出新,以迅雷 ...

  4. JS处理四舍五入函数 toFixed(n)(可取小数点后n位)

    在JS中四舍五入的函数 toFixed(n) , n为要保留的小数位数. n为0~20,当n超过20的时候,JS会出错. 如果小数点前和要截取的前一位都是0时,不会按常理截取.       var h ...

  5. .net ServiceStack.Redis 性能调优

    最近在debug生产环境的问题时,发现了ServiceStack 4.0.60版本RedisClient存在一个非常严重的性能问题.在高并发下,PooledRedisClientManager.Get ...

  6. C#程序员的春天之从零开始学习unity3D游戏开发入门教程二(创建项目及基本面板介绍)

    一项目创建: 创建项目是开发的第一步. 运行untiy之后如果是第一次运行会弹出 我们这里随便创建一个项目. 二Untiy面板介绍: 三代码编辑器的切换: 这里我安装了vs2012. 到这里开发环境基 ...

  7. Redis集群(三):主从配置一

    一.本文目的          Redis的主从配置分为两篇文章,第一篇主要介绍了Redis主从配置的搭建过程及使用,第二篇主要说明各种情况下Redis主从状态,如Master挂掉,Slaver挂掉, ...

  8. 【BZOJ 4561】【JLOI 2016】圆的异或并

    http://www.lydsy.com/JudgeOnline/problem.php?id=4561 一开始并不会做,后来看题解看懂了. 看懂了之后还是错了好几次,数组大小手残开小了. 圆的包含并 ...

  9. Dirac Delta Function

    也称为Degenerate pdf, 退化概率密度函数. 未经考证的解释是: 当正态分布的\(\sigma \to 0\)时, 正态分布就退化为这个分布了. 定义 \[ \delta(x) = \be ...

  10. Filter(过滤器)学习

    一.Filter简介 Filter也称之为过滤器,它是Servlet技术中最激动人心的技术,WEB开发人员通过Filter技术,对web服务器管理的所有web资源:例如Jsp, Servlet, 静态 ...