代理模式

安卓AudioBuffer流程 Audio buffer流程介绍 版本 时间 作者 描述 V1.0 2021.09317 王嘉豪 buffer介绍 概述: Audio buffer流程介绍 目录 framework hardware kernel Framework 共享内存的创建: AudioFlinger::ThreadBase::TrackBase::TrackBase() if (client != 0) { mCblkMemory = client->heap()->alloc 阅读详情

A是B的代理,对B的访问都可以通过对A的访问来实现。为什么要这样?因为对B的访问可能需要跨进程,可能需要复杂的逻辑判断,可能需要。。。总之比较麻烦,所以B为了提供给别人一个好用的接口,就创建了自己的代理A。

在大名鼎鼎的Binder通信里,就是用Bp来做Bn的代理,Bp可以放在访问者进程里,从而封装了麻烦的跨进程调用。



还有一个例子是AudioTrack和AudioFlinger在操作匿名共享内存的时候,使用了ClientProxy,ServerProxy。我们可以看到,它们提供的接口都是类似的,但是却封装了复杂的循环buffer前后指针判断逻辑和跨进程操作。



{
protected:
    ServerProxy(audio_track_cblk_t* cblk, void *buffers, size_t frameCount, size_t frameSize,
            bool isOut, bool clientInServer);
public:
    virtual ~ServerProxy() { }

    // Obtain a buffer with filled frames (writing) or empty frames (reading).
    // It is permitted to call obtainBuffer() multiple times in succession, without any intervening
    // calls to releaseBuffer().  In that case, the final obtainBuffer() is the one that effectively
    // sets or extends the unreleased frame count.
    // Always non-blocking.
    // On entry:
    //  buffer->mFrameCount should be initialized to maximum number of desired frames,
    //      which must be > 0.
    //  buffer->mNonContig is unused.
    //  buffer->mRaw is unused.
    //  ackFlush is true iff being called from Track::start to acknowledge a pending flush.
    // On exit:
    //  buffer->mFrameCount has the actual number of contiguous available frames,
    //      which is always 0 when the return status != NO_ERROR.
    //  buffer->mNonContig is the number of additional non-contiguous available frames.
    //  buffer->mRaw is a pointer to the first available frame,
    //      or NULL when buffer->mFrameCount == 0.
    // The return status is one of:
    //  NO_ERROR    Success, buffer->mFrameCount > 0.
    //  WOULD_BLOCK No frames are available.
    //  NO_INIT     Shared memory is corrupt.
    virtual status_t    obtainBuffer(Buffer* buffer, bool ackFlush = false);

    // Release (some of) the frames last obtained.
    // On entry, buffer->mFrameCount should have the number of frames to release,
    // which must (cumulatively) be <= the number of frames last obtained but not yet released.
    // It is permitted to call releaseBuffer() multiple times to release the frames in chunks.
    // buffer->mRaw is ignored, but is normally same pointer returned by last obtainBuffer().
    // On exit:
    //  buffer->mFrameCount is zero.
    //  buffer->mRaw is NULL.
    virtual void        releaseBuffer(Buffer* buffer);

protected:
    size_t      mAvailToClient; // estimated frames available to client prior to releaseBuffer()
    int32_t     mFlush;         // our copy of cblk->u.mStreaming.mFlush, for streaming output only
}
// Proxy seen by AudioTrack client and AudioRecord client
class ClientProxy : public Proxy {
public:
    ClientProxy(audio_track_cblk_t* cblk, void *buffers, size_t frameCount, size_t frameSize,
            bool isOut, bool clientInServer);
    virtual ~ClientProxy() { }

    static const struct timespec kForever;
    static const struct timespec kNonBlocking;

    // Obtain a buffer with filled frames (reading) or empty frames (writing).
    // It is permitted to call obtainBuffer() multiple times in succession, without any intervening
    // calls to releaseBuffer().  In that case, the final obtainBuffer() is the one that effectively
    // sets or extends the unreleased frame count.
    // On entry:
    //  buffer->mFrameCount should be initialized to maximum number of desired frames,
    //      which must be > 0.
    //  buffer->mNonContig is unused.
    //  buffer->mRaw is unused.
    //  requested is the requested timeout in local monotonic delta time units:
    //      NULL or &kNonBlocking means non-blocking (zero timeout).
    //      &kForever means block forever (infinite timeout).
    //      Other values mean a specific timeout in local monotonic delta time units.
    //  elapsed is a pointer to a location that will hold the total local monotonic time that
    //      elapsed while blocked, or NULL if not needed.
    // On exit:
    //  buffer->mFrameCount has the actual number of contiguous available frames,
    //      which is always 0 when the return status != NO_ERROR.
    //  buffer->mNonContig is the number of additional non-contiguous available frames.
    //  buffer->mRaw is a pointer to the first available frame,
    //      or NULL when buffer->mFrameCount == 0.
    // The return status is one of:
    //  NO_ERROR    Success, buffer->mFrameCount > 0.
    //  WOULD_BLOCK Non-blocking mode and no frames are available.
    //  TIMED_OUT   Timeout occurred before any frames became available.
    //              This can happen even for infinite timeout, due to a spurious wakeup.
    //              In this case, the caller should investigate and then re-try as appropriate.
    //  DEAD_OBJECT Server has died or invalidated, caller should destroy this proxy and re-create.
    //  -EINTR      Call has been interrupted.  Look around to see why, and then perhaps try again.
    //  NO_INIT     Shared memory is corrupt.
    // Assertion failure on entry, if buffer == NULL or buffer->mFrameCount == 0.
    status_t    obtainBuffer(Buffer* buffer, const struct timespec *requested = NULL,
            struct timespec *elapsed = NULL);

    // Release (some of) the frames last obtained.
    // On entry, buffer->mFrameCount should have the number of frames to release,
    // which must (cumulatively) be <= the number of frames last obtained but not yet released.
    // buffer->mRaw is ignored, but is normally same pointer returned by last obtainBuffer().
    // It is permitted to call releaseBuffer() multiple times to release the frames in chunks.
    // On exit:
    //  buffer->mFrameCount is zero.
    //  buffer->mRaw is NULL.
    void        releaseBuffer(Buffer* buffer);

    // Call after detecting server's death
    void        binderDied();

    // Call to force an obtainBuffer() to return quickly with -EINTR
    void        interrupt();

    size_t      getPosition() {
        return mEpoch + mCblk->mServer;
    }

    void        setEpoch(size_t epoch) {
        mEpoch = epoch;
    }

    void        setMinimum(size_t minimum) {
        // This can only happen on a 64-bit client
        if (minimum > UINT32_MAX) {
            minimum = UINT32_MAX;
        }
        mCblk->mMinimum = (uint32_t) minimum;
    }

    // Return the number of frames that would need to be obtained and released
    // in order for the client to be aligned at start of buffer
    virtual size_t  getMisalignment();

    size_t      getEpoch() const {
        return mEpoch;
    }

    size_t      getFramesFilled();

private:
    size_t      mEpoch;
};


Audio笔记之AudioTrack::write public int write(byte[] audioData, int offsetInBytes, int sizeInBytes) { if (mState == STATE_UNINITIALIZED) { return ERROR_INVALID_OPERATION; } if ( (audioData == 阅读详情

相关推荐

JS设计模式之代理模式

Star这个类就是明星,StarProxy这个类就是明星经纪人,假如我们是商家,现在我们想请这个明星来参加我们的活动,我们开始和经纪人谈价格,talk出价1w,此时经纪人会做一个判断,如果价格大于等于1w,这个活动就比较适合,可以参加,代理就会去通知明星演出,如果小于1w的话,就不会,这个就是简单的代理模式,我们要访问明星,需要经过经纪人(也就是代理),才能去访问。其实就是给一个对象提供一个代理,如果要访问这个对象必须经过这个代理,先说,这个模式的优点是什么。

MRDONG1的博客 1537

Android Audio System深入探究之AudioTrack(基于Android9)

文章目录1. 音频系统概述2. 放音流程分析2.1 getMinBufferSize2.2 AudioTrack2.3 AudioTrack (Native空间) set分析2.3.1 Cblk 在AF端初始化2.3.2 IAudioTrack和AT、AF的关系2.3.3 共享内存与cblk2.4 play和write分析2.5 obtainBuffer 和releaseBuffer2.6 delete AudioTrack2.7 stop分析AudioTrack流程总结 基于Android 9 1. 音

虎哥LoveDroid 3077

利用Pandas进行高效网络数据获取

本文将重点介绍如何使用Pandas库进行网络爬虫。爬取数据是获取互联网上信息的常见方式之一,而Pandas作为一种强大的数据处理和分析工具,为我们提供了便捷的方法来处理和清洗从网页上获取的数据。文章将从爬取网页数据开始,包括使用Python的Requests库发送HTTP请求获取网页内容,并使用Pandas的功能来解析和提取所需的数据。我们还将讨论如何处理网页中的表格数据、处理和清洗数据、保存数据到文件等常见任务。

ak_bingbing的博客 1439

08.音频系统:第004课_Android音频系统详解:第010节_音频数据的传递

通过前面的学习,在应用程序中,每创建一个AudioTrack,在AudioFlinger边,某个playbackThread中就会创建一个Track与其对应,Track与AudioTrack之间,通过共享内存传递音频数据,那么怎么传递这个数据呢?其实非常的简单,分为两种情况 1.MODE_STATIC:一次性,提前提供数据。 2.MODE_STREAM:多次传输,是一边播放,一边提供数据 在第一种......

江南才尽江南山,年少无知年少狂! 2272

IT资产管理(三)之GLPI资产录入

glpi 在 10 版本之后已经有自带的 glpi-agent 代理程序可自动获取服务器、电脑等的信息并进行自动录入和更新,不再依赖 10 版本之前的 fusioninventory 插件或者第三方资产统计平台 OCS Inventory 等

予挚之的博客 2992

Claude Code Router 401错误修复

claude code router配置相关环境变量问题

如沐春风 6360

设计模式之代理模式ProxyPattern(六)

1、什么是代理模式?代理模式是23种设计模式中的一种。代理模式是一种结构型设计模式,它允许为其他对象提供一个替代品或占位符,以控制对这个对象的访问。2、代理模式的角色构成抽象主题(Subject):定义了真实主题和代理主题的共同接口,这样代理类可以通过实现该接口来代理真实主题。真实主题(Real Subject):定义了代理所代表的真实对象。代理(Proxy):持有对真实主题的引用,并实现了与真实主题一样的接口,客户端通过代理来访问真实主题,同时可以在访问真实主题前后进行一些额外操作。

徐泗空的博客 1465

向量化和向量数据库的开发步骤,以及本地docker下载Redis-stack-server,以及如何将文本转成向量,以及文本向量化成功后将数据存入到Redis-stack-server这个向量数据库

内存可以作为向量数据库,但是一重启一断电数据就没了这了选择RedisStack作为向量数据,用来向量的存储,未来会改名成Redis8,也就是在原本的Reids的功能上增加了新的特性,本质上还是Redis向量数据库还可以用ElaticSearch、MongoDB等。

qq_61723836的博客 1083

代理模式(ProxyPattern)

代理模式(ProxyPattern) 代理模式 为其他对象提供一种代理以控制对这个对象的访问 远程代理,也就是为一个对象在不同的地址控件提供局部代表。这样可以隐藏一个对象存在于不同地址空间的事实 虚拟代理,根据需要创建开销很大的对象,通过他来存储实例化需要很长时间的真是对象 安全代理 用来控制真实对象访问时的权限 智能指引 指当调用真实的对象时,代理处理另外一些事情 模式动机 在某些情况下,一个客户不想或者不能直接引用一个对 象,此时可以通过一个称之为“代理”的第三者来实现 间接引用。代理对象可以在客户

Sharker_Blog的博客 584

MATLAB功率谱函数psd与pwelch的使用

在网上看到 clear; Fs=1000; n=0:1/Fs:1; y=cos(2*pi*40*n)+3*cos(2*pi*100*n)+randn(size(n)); Nfft=1000; window=hanning(100); noverlap=20; dflag='none'; [Pxx,f]=psd(y,Nfft,Fs,window,noverlap); figure plot(f,10*log10(Pxx)); xlabel('frequency/Hz');ylab

qq_41687938的博客 2万+

蓝牙 - 如何在Windows下抓取蓝牙数据

选择Windows Instarller(64-bit),最好不要选择PortableApps版,因为后面需要通过btvs.exe来启动Wireshark,如果是绿色可移植版,会启动失败。在安装完以后,找到btvs.exe文件,位于路径:C:\BTP\v1.14.0\x86下,这个视安装版本不同路径名不同。在第一台机器上启动btvs.exe,第二台机器上手动启动wireshark,并将第一台机器的IP地址作为参数。1,同一机器上,Wireshark安装后,会自动直接启动,如上面使用方式一样。

guoqx的专栏 2万+

代理模式 (ProxyPattern)

文章目录代理模式 (ProxyPattern)代理模式的定义代理模式的优点代理模式的缺点代理模式的结构代理模式的实现普通代理强制代理动态代理AOP使用场景 代理模式 (ProxyPattern) 代理模式的定义 为其他对象提供一种代理以控制对这个对象的访问。 代理模式的优点 真实的角色就是实现实际的业务逻辑,不用关心其他非本职责的事务,通过后期的代理完成一件事务,附带的结果就是编程简洁清晰。 具体主题角色是随时都会发生变化的,只要它实现了接口,甭管它如何变化,都逃不脱如来佛的手掌(接口),那我们的代理类完

有问题的请私信或关注v【技术印记】留言 414

高通平台 Android T 蓝牙技术全解析:架构、代码与实现原理

协议栈、配置文件和服务都运行在一个独立的用户空间进程。

专业开发者的博客,一个从事Android WiFi和蓝牙的工程师 100

设计模式之代理模式(ProxyPattern)

设计模式之代理模式(ProxyPattern) 文章目录设计模式之代理模式(ProxyPattern)一.代理模式(ProxyPattern)二.编程实例1.图片读取案例2.String类访问修饰符[]读写操作区分案例 一.代理模式(ProxyPattern) 代理模式是创建一个代理类,来帮助我们处理真实类,一般来说,这种代理类有点像明星的经纪人,如果你想接触到明星,必须先和他们的经纪人打交道。...

Worthy_Wang的博客 476

GeoXCP:可解释人工智能中空间解释的不确定性量化

GeoXCP: uncertainty quantification of spatial explanations in explainable AI提出基于保形预测(conformal prediction)的不确定性量化框架——地理空间解释保形预测(GeoXCP),将空间依赖纳入建模过程,生成具有校准不确定性估计的空间自适应解释。通过大量模拟实验和真实世界数据集验证,GeoXCP在不同地理空间场景中能提供可靠解释并有效量化不确定性,推动可解释地理空间机器学习的发展,帮助决策者评估模型驱动洞察的可信度。

May the Force be with you 243

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

代理模式-ProxyPattern

前言: 代理模式与装饰者模式: 相同点: 1. 前提条件:装饰者(代理者)与被装饰者(委托者)要继承相同的父类或实现相同的接口。 2. 都可以增强某个类的方法,对程序进行扩展。 不同点: 1. 代理者是为某个对象添加一个代理,以控制对这个对象的访问。而装饰者增强某个类的方法。 2. 代理可以在调用核心方法之前做前置处理...

Jason Blog 197

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

代理模式(ProxyPattern)

定义 通过一个代理对象或者占位符来控制对原对象的访问。 结构图 角色与理解 代理模式共分为四种角色: Subject(抽象主题角色):真实主题角色与代理主题角色的共同父类,可以是具体类、抽象类、接口,客户端针对抽象主题角色编程 RealSubject(真实主题角色):实现具体业务方法的类,被代理主题角色调用 Proxy(代理主题角色):持有真实主题角色的引用,在调用真实主题角色的具体业务方法之前或者之后添加其它操作 客户端面对抽象主题角色编程,调用抽象主题角色实际上调用的是代

码农架构 422

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

java设计模式之 代理模式【Proxy Pattern】 详解

首先我们举个例子说明一下什么是策略模式: 什么是代理模式呢?我很忙,忙的没空理你,那你要找我呢就先找我的代理人吧,那代理人总要知道 被代理人能做哪些事情不能做哪些事情吧,那就是两个人具备同一个接口,代理人虽然不能干活,但是被 代理的人能干活呀。 比如西门庆找潘金莲,那潘金莲不好意思答复呀,咋办,找那个王婆做代理,表现在程序上时这样的: 先定义一种类型的女人: package com.cbf4lif...

蛋蛋淡淡定的庄园 299

结构型模型之-代理模式(proxyPattern)

结构型模型之-代理模式(proxyPattern) 参考网址:https://www.runoob.com/design-pattern/proxy-pattern.html 1 代理模式简介 代理模式主要是用中间层控制原生对象的访问 和装饰器模式的区别:装饰器模式为了增强功能,而代理模式是为了加以控制。 2 代理模式图解 3 代理模式简单实现 3.1 代码组成类 Image ProxyImage RealImage TestProxy 3.2 具体代码 Image package com.sh

shufangreal的博客 331

代理模式(proxyPattern)

定义  为其他对象提供一种代理以控制这个对象的访问。在某些情况下,一个对象不适合或者不能直接引用另一个对象,而代理模式可以在客户端与目标对象之间起到中介的作用。分类  1.静态代理:由程序员创建或特定工具自动生成源代码,再对其编译。在程序运行前,代理类的.class文件就已经存在了。  2.动态代理:在程序运行时,运用反射机制动态创建而程。UML...

zz_ddup的博客 221

第6章 代理模式【ProxyPattern】

静态代理的目标对象和代理对象需要实现统一个接口或者继承相同的父类。JDK动态代理的代理对象不需要实现接口,但是目标对象需要实现接口。

qq_41846002的博客 423
上一篇: 核间通信原理
下一篇: Android多媒体:AudioSystem,AudioService和AudioManager
我把葡萄酿成酒
博客等级 码龄12年 275粉丝 198原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值