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. CH Round #72树洞[二分答案 DFS&&BFS]

    树洞 CH Round #72 - NOIP夏季划水赛 描述 在一片栖息地上有N棵树,每棵树下住着一只兔子,有M条路径连接这些树.更特殊地是,只有一棵树有3条或更多的路径与它相连,其它的树只有1条或2 ...

  2. SSH-Hibernate+Struts2+Spring的股票项目整合

    创建项目之前:我们需要导入我们需要的Hibernate和Struts2和Spring的相关架包.(博客自创,如有问题请留言博主,拒绝盗版,支持正版http://www.cnblogs.com/WuXu ...

  3. tagfield

  4. Revolving Digits[EXKMP]

    Revolving Digits Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  5. AndroidStudio导入Eclipse的代码格式化文件

    对于一个团队来说,使用统一的代码格式是非常重要的,否则在使用版本控制工具时,会出现大量的冲突.在Eclipse里,我们可以通过一些xml来进行代码格式的统一,但是这些文件要应用在AndroidStud ...

  6. ASP.NET(C#) Web Api通过文件流下载文件到本地实例

    下载文件到本地是很多项目开发中需要实现的一个很简单的功能.说简单,是从具体的代码实现上来说的,.NET的文件下载方式有很多种,本示例给大家介绍的是ASP.NET Web Api方式返回HttpResp ...

  7. rpc框架之HA/负载均衡构架设计

    thrift.avro.grpc之类的rpc框架默认都没有提供负载均衡的实现,生产环境中如果server只有一台,显然不靠谱,于是有了下面的设计,这其实是前一阵跟北京一个朋友在qq群里交流的结果,分享 ...

  8. SQL数据库分配权限

    打开SQL-Server管理工具->安全性->登陆名->右键(新建登陆名) 输入相应的信息(这里要去掉强制实施密码策略,强制密码过期,否则用户在下次登录时必须修改密码) 用户映射-& ...

  9. C# 与 SQLite的操作

    1.通过Add References引用SQLite ADO .NET安装目录的bin目录下的System.Data.SQLite.DLL. 2.创建数据库文件:因为始终是个0字节文件,应该利用IO也 ...

  10. 用Jedis连接Redis

    jedis中的方法名,和Redis的命令几乎一样 1.jar包,作为测试只需要一个jar 2.代码 package com; import java.util.HashMap; import java ...