Esempio n. 1
0
void GrAtlasTextBatch::onPrepareDraws(Target* target) const {
    // if we have RGB, then we won't have any SkShaders so no need to use a localmatrix.
    // TODO actually only invert if we don't have RGBA
    SkMatrix localMatrix;
    if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) {
        SkDebugf("Cannot invert viewmatrix\n");
        return;
    }

    GrTexture* texture = fFontCache->getTexture(this->maskFormat());
    if (!texture) {
        SkDebugf("Could not allocate backing texture for atlas\n");
        return;
    }

    GrMaskFormat maskFormat = this->maskFormat();

    SkAutoTUnref<const GrGeometryProcessor> gp;
    if (this->usesDistanceFields()) {
        gp.reset(this->setupDfProcessor(this->viewMatrix(), fFilteredColor, this->color(),
                                        texture));
    } else {
        GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode);
        gp.reset(GrBitmapTextGeoProc::Create(this->color(),
                                             texture,
                                             params,
                                             maskFormat,
                                             localMatrix,
                                             this->usesLocalCoords()));
    }

    FlushInfo flushInfo;
    flushInfo.fGlyphsToFlush = 0;
    size_t vertexStride = gp->getVertexStride();
    SkASSERT(vertexStride == GrAtlasTextBlob::GetVertexStride(maskFormat));

    target->initDraw(gp);

    int glyphCount = this->numGlyphs();
    const GrBuffer* vertexBuffer;

    void* vertices = target->makeVertexSpace(vertexStride,
                                             glyphCount * kVerticesPerGlyph,
                                             &vertexBuffer,
                                             &flushInfo.fVertexOffset);
    flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer));
    flushInfo.fIndexBuffer.reset(target->resourceProvider()->refQuadIndexBuffer());
    if (!vertices || !flushInfo.fVertexBuffer) {
        SkDebugf("Could not allocate vertices\n");
        return;
    }

    unsigned char* currVertex = reinterpret_cast<unsigned char*>(vertices);

    // We cache some values to avoid going to the glyphcache for the same fontScaler twice
    // in a row
    const SkDescriptor* desc = nullptr;
    SkGlyphCache* cache = nullptr;
    GrFontScaler* scaler = nullptr;
    SkTypeface* typeface = nullptr;

    GrBlobRegenHelper helper(this, target, &flushInfo, gp);

    for (int i = 0; i < fGeoCount; i++) {
        const Geometry& args = fGeoData[i];
        Blob* blob = args.fBlob;
        size_t byteCount;
        void* blobVertices;
        int subRunGlyphCount;
        blob->regenInBatch(target, fFontCache, &helper, args.fRun, args.fSubRun, &cache,
                           &typeface, &scaler, &desc, vertexStride, args.fViewMatrix, args.fX,
                           args.fY, args.fColor, &blobVertices, &byteCount, &subRunGlyphCount);

        // now copy all vertices
        memcpy(currVertex, blobVertices, byteCount);

#ifdef SK_DEBUG
        // bounds sanity check
        SkRect rect;
        rect.setLargestInverted();
        SkPoint* vertex = (SkPoint*) ((char*)blobVertices);
        rect.growToInclude(vertex, vertexStride, kVerticesPerGlyph * subRunGlyphCount);

        if (this->usesDistanceFields()) {
            args.fViewMatrix.mapRect(&rect);
        }
        SkASSERT(fBounds.contains(rect));
#endif

        currVertex += byteCount;
    }

    // Make sure to attach the last cache if applicable
    if (cache) {
        SkGlyphCache::AttachCache(cache);
    }
    this->flush(target, &flushInfo);
}
 bool helper(TreeNode* s, TreeNode* t){
     if(!s && !t) return true;
     if(!s || !t) return false;
     if(s->val != t->val) return false;
     return helper(s->left, t->left) && helper(s->right, t->right);
 }
 TreeNode* invertTree(TreeNode* root) {
     TreeNode* p = root;
     helper(p);
     return root;
 }
Esempio n. 4
0
TEST(pthread, pthread_mutex_ERRORCHECK_wakeup) {
  MutexWakeupHelper helper(PTHREAD_MUTEX_ERRORCHECK);
  helper.test();
}
Esempio n. 5
0
int main(void){
    helper(fun);
    return 0;
}
Esempio n. 6
0
 vector<vector<int>> combine(int n, int k) {
     vector<vector<int>> res;
     vector<int> sol;
     helper(res,sol,n,k,1);
     return res;
 }
Esempio n. 7
0
 int closestValue(TreeNode* root, double target) {
     
     int closet = root->val;
     helper(root, target, closet);
     return closet;
 }
Esempio n. 8
0
 int rob(TreeNode* root) {
     int l,r;
     return helper(root,l,r);
 }
 int kthSmallest(TreeNode* root, int k){
     this->k = k;
     helper(root);
     return ret;
 }
Esempio n. 10
0
Box* interpretFunction(llvm::Function* f, int nargs, Box* closure, Box* generator, Box* arg1, Box* arg2, Box* arg3,
                       Box** args) {
    assert(f);

#ifdef TIME_INTERPRETS
    Timer _t("to interpret", 1000000);
    long this_us = 0;
#endif

    static StatCounter interpreted_runs("interpreted_runs");
    interpreted_runs.log();

    llvm::DataLayout dl(f->getParent());

    // f->dump();
    // assert(nargs == f->getArgumentList().size());

    SymMap symbols;

    void* frame_ptr = __builtin_frame_address(0);
    root_stack_set.get()->push_back(&symbols);
    UnregisterHelper helper(frame_ptr);

    int arg_num = -1;
    int closure_indicator = closure ? 1 : 0;
    int generator_indicator = generator ? 1 : 0;
    int arg_offset = closure_indicator + generator_indicator;
    for (llvm::Argument& arg : f->args()) {
        arg_num++;

        if (arg_num == 0 && closure)
            symbols.insert(std::make_pair(static_cast<llvm::Value*>(&arg), Val(closure)));
        else if ((arg_num == 0 || (arg_num == 1 && closure)) && generator)
            symbols.insert(std::make_pair(static_cast<llvm::Value*>(&arg), Val(generator)));
        else if (arg_num == 0 + arg_offset)
            symbols.insert(std::make_pair(static_cast<llvm::Value*>(&arg), Val(arg1)));
        else if (arg_num == 1 + arg_offset)
            symbols.insert(std::make_pair(static_cast<llvm::Value*>(&arg), Val(arg2)));
        else if (arg_num == 2 + arg_offset)
            symbols.insert(std::make_pair(static_cast<llvm::Value*>(&arg), Val(arg3)));
        else {
            assert(arg_num == 3 + arg_offset);
            assert(f->getArgumentList().size() == 4 + arg_offset);
            assert(f->getArgumentList().back().getType() == g.llvm_value_type_ptr->getPointerTo());
            symbols.insert(std::make_pair(static_cast<llvm::Value*>(&arg), Val((int64_t)args)));
            // printf("loading %%4 with %p\n", (void*)args);
            break;
        }
    }

    llvm::BasicBlock* prevblock = NULL;
    llvm::BasicBlock* curblock = &f->getEntryBlock();

    // The symbol table at the end of the previous BB
    // This is important for the following case:
    // %a = phi [0, %l1], [1, %l2]
    // %b = phi [0, %l1], [%a, %l2]
    // The reference to %a in the definition of %b resolves to the *previous* value of %a,
    // not the value of %a that we just set in the phi.
    SymMap prev_symbols;

    struct {
        Box* exc_obj;
        int64_t exc_selector;
    } landingpad_value;

    while (true) {
        for (llvm::Instruction& _inst : *curblock) {
            llvm::Instruction* inst = &_inst;
            cur_instruction_map[frame_ptr] = inst;

            if (VERBOSITY("interpreter") >= 2) {
                printf("executing in %s: ", f->getName().data());
                fflush(stdout);
                inst->dump();
                // f->dump();
            }

#define SET(v) set(symbols, inst, (v))

            if (llvm::LandingPadInst* lpad = llvm::dyn_cast<llvm::LandingPadInst>(inst)) {
                SET((intptr_t)&landingpad_value);
                continue;
            } else if (llvm::ExtractValueInst* ev = llvm::dyn_cast<llvm::ExtractValueInst>(inst)) {
                Val r = fetch(ev->getAggregateOperand(), dl, symbols);
                llvm::ArrayRef<unsigned> indexes = ev->getIndices();

#ifndef NDEBUG
                assert(indexes.size() == 1);
                llvm::Type* t = llvm::ExtractValueInst::getIndexedType(ev->getAggregateOperand()->getType(), indexes);
                assert(width(t, dl) == 8);
#endif

                int64_t* ptr = (int64_t*)r.n;
                int64_t val = ptr[indexes[0]];
                SET(val);
                continue;
            } else if (llvm::LoadInst* li = llvm::dyn_cast<llvm::LoadInst>(inst)) {
                llvm::Value* ptr = li->getOperand(0);
                Val v = fetch(ptr, dl, symbols);
                // printf("loading from %p\n", v.o);

                if (width(li, dl) == 1) {
                    Val r = Val(*(bool*)v.o);
                    SET(r);
                    continue;
                } else if (width(li, dl) == 8) {
                    Val r = Val(*(int64_t*)v.o);
                    SET(r);
                    continue;
                } else {
                    li->dump();
                    RELEASE_ASSERT(0, "");
                }
            } else if (llvm::StoreInst* si = llvm::dyn_cast<llvm::StoreInst>(inst)) {
                llvm::Value* val = si->getOperand(0);
                llvm::Value* ptr = si->getOperand(1);
                Val v = fetch(val, dl, symbols);
                Val p = fetch(ptr, dl, symbols);

                // printf("storing %lx at %lx\n", v.n, p.n);

                if (width(val, dl) == 1) {
                    *(bool*)p.o = v.b;
                    continue;
                } else if (width(val, dl) == 8) {
                    *(int64_t*)p.o = v.n;
                    continue;
                } else {
                    si->dump();
                    RELEASE_ASSERT(0, "");
                }
            } else if (llvm::CmpInst* ci = llvm::dyn_cast<llvm::CmpInst>(inst)) {
                assert(ci->getType() == g.i1);

                Val a0 = fetch(ci->getOperand(0), dl, symbols);
                Val a1 = fetch(ci->getOperand(1), dl, symbols);
                llvm::CmpInst::Predicate pred = ci->getPredicate();
                switch (pred) {
                    case llvm::CmpInst::ICMP_EQ:
                        SET(a0.n == a1.n);
                        continue;
                    case llvm::CmpInst::ICMP_NE:
                        SET(a0.n != a1.n);
                        continue;
                    case llvm::CmpInst::ICMP_SLT:
                        SET(a0.n < a1.n);
                        continue;
                    case llvm::CmpInst::ICMP_SLE:
                        SET(a0.n <= a1.n);
                        continue;
                    case llvm::CmpInst::ICMP_SGT:
                        SET(a0.n > a1.n);
                        continue;
                    case llvm::CmpInst::ICMP_SGE:
                        SET(a0.n >= a1.n);
                        continue;
                    case llvm::CmpInst::FCMP_OEQ:
                        SET(a0.d == a1.d);
                        continue;
                    case llvm::CmpInst::FCMP_UNE:
                        SET(a0.d != a1.d);
                        continue;
                    case llvm::CmpInst::FCMP_OLT:
                        SET(a0.d < a1.d);
                        continue;
                    case llvm::CmpInst::FCMP_OLE:
                        SET(a0.d <= a1.d);
                        continue;
                    case llvm::CmpInst::FCMP_OGT:
                        SET(a0.d > a1.d);
                        continue;
                    case llvm::CmpInst::FCMP_OGE:
                        SET(a0.d >= a1.d);
                        continue;
                    default:
                        ci->dump();
                        RELEASE_ASSERT(0, "");
                }
                continue;
            } else if (llvm::BinaryOperator* bo = llvm::dyn_cast<llvm::BinaryOperator>(inst)) {
                if (bo->getOperand(0)->getType() == g.i64 || bo->getOperand(0)->getType() == g.i1) {
                    // assert(bo->getOperand(0)->getType() == g.i64);
                    // assert(bo->getOperand(1)->getType() == g.i64);

                    Val a0 = fetch(bo->getOperand(0), dl, symbols);
                    Val a1 = fetch(bo->getOperand(1), dl, symbols);
                    llvm::Instruction::BinaryOps opcode = bo->getOpcode();
                    switch (opcode) {
                        case llvm::Instruction::Add:
                            SET(a0.n + a1.n);
                            continue;
                        case llvm::Instruction::And:
                            SET(a0.n & a1.n);
                            continue;
                        case llvm::Instruction::AShr:
                            SET(a0.n >> a1.n);
                            continue;
                        case llvm::Instruction::Mul:
                            SET(a0.n * a1.n);
                            continue;
                        case llvm::Instruction::Or:
                            SET(a0.n | a1.n);
                            continue;
                        case llvm::Instruction::Shl:
                            SET(a0.n << a1.n);
                            continue;
                        case llvm::Instruction::Sub:
                            SET(a0.n - a1.n);
                            continue;
                        case llvm::Instruction::Xor:
                            SET(a0.n ^ a1.n);
                            continue;
                        default:
                            bo->dump();
                            RELEASE_ASSERT(0, "");
                    }
                    continue;
                } else if (bo->getOperand(0)->getType() == g.double_) {
                    // assert(bo->getOperand(0)->getType() == g.i64);
                    // assert(bo->getOperand(1)->getType() == g.i64);

                    double lhs = fetch(bo->getOperand(0), dl, symbols).d;
                    double rhs = fetch(bo->getOperand(1), dl, symbols).d;
                    llvm::Instruction::BinaryOps opcode = bo->getOpcode();
                    switch (opcode) {
                        case llvm::Instruction::FAdd:
                            SET(lhs + rhs);
                            continue;
                        case llvm::Instruction::FMul:
                            SET(lhs * rhs);
                            continue;
                        case llvm::Instruction::FSub:
                            SET(lhs - rhs);
                            continue;
                        default:
                            bo->dump();
                            RELEASE_ASSERT(0, "");
                    }
                    continue;
                } else {
                    bo->dump();
                    RELEASE_ASSERT(0, "");
                }
            } else if (llvm::GetElementPtrInst* gep = llvm::dyn_cast<llvm::GetElementPtrInst>(inst)) {
Esempio n. 11
0
 int numDistinct(string s, string t) {
     vector<vector<int>> table(s.size() + 1, vector<int>(t.size() + 1, -1));//table[0]不存数
     return helper(s, t, s.size(), t.size(), table);
 }
Esempio n. 12
0
bool BackendHelper::DumpAllRegisters(IoBackend *backend, bool ignore_errors)
{
    BackendHelper helper(backend, m_soc);
    return DumpAllRegisters(&helper, m_soc.root_inst(), ignore_errors);
}
Esempio n. 13
0
 vector<vector<int>> getFactors(int n) {
     vector<vector<int>> res;
     helper(n, 2, {}, res);
     return res;
 }
Esempio n. 14
0
 /**
  * @param A: an integer array.
  * @param k: a positive integer (k <= length(A))
  * @param target: a integer
  * @return a list of lists of integer
  */
 vector<vector<int> > kSumII(vector<int> A, int k, int target) {
     vector<vector<int>> ans;
     vector<int> curr;
     helper(A, k, 0, target, curr, ans);
     return ans;
 }
Esempio n. 15
0
int main(int argc, char **argv)
{
	int sock;
	struct addrinfo hints, *results;
	struct sockaddr_in addr;
	socklen_t size;
	
	char *host, *port;
	
	int client;

	int reuseaddr;
	
	reuseaddr = 1;
    /* Get the server host and port from the command line */
    if (argc < 2) 
    {
        fprintf(stderr, "Syntax: %s [Host of Server] [Port of Server]\n", argv[0]);
        exit(1);
    }
    host = argv[1];
    port = argv[2];

    /* Get the address info */
    memset(&hints, 0, sizeof hints);
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;
    /*Use our own IP*/
    hints.ai_flags = AI_PASSIVE;
    if (getaddrinfo(NULL, PORT, &hints, &results) != 0) 
    {
        perror("getaddrinfo");
        exit(1);
    }

    /* Create the socket */
    sock = socket(results->ai_family, results->ai_socktype, results->ai_protocol);
    if (sock == -1) {
        perror("socket");
        freeaddrinfo(results);
        exit(1);
    }

    /* Enable the socket to reuse the address */
    if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(int)) == -1) {
        perror("setsockopt");
        freeaddrinfo(results);
        exit(1);
    }

    /* Bind to the address */
    if (bind(sock, results->ai_addr, results->ai_addrlen) == -1) {
        perror("bind");
        freeaddrinfo(results);
        exit(1);
    }

    /* Listen */
    if (listen(sock, BACKLOG) == -1) {
        perror("listen");
        freeaddrinfo(results);
        exit(1);
    }

    freeaddrinfo(results);

    /* Ignore broken pipe signal */
    signal(SIGPIPE, SIG_IGN);

    /* Main loop */
    while (1) {
        size = sizeof addr;
        
        client = accept(sock, (struct sockaddr*)&addr, &size);
        if (client == -1) 
        {
            perror("accept");
        }
        else 
        {
            printf("Connection from %s\n", inet_ntoa(addr.sin_addr));
			helper(client, host, port);
		}    
            
    }

    close(sock);

    return 0;
}
Esempio n. 16
0
 double soupServings(int N) 
 {
     return helper(N, N);
 }
Esempio n. 17
0
static void do_join(struct coopth_per_thread_t *pth, void (*helper)(void))
{
    while (pth->st.state != COOPTHS_NONE)
	helper();
}
Esempio n. 18
0
 double soupServings(int N) 
 {
     return N > 4800 ? 1 : helper(std::ceil(N/25.0), std::ceil(N/25.0));
 }
Esempio n. 19
0
/*!
  \brief Draw a set of points of a curve.

  When observing an measurement while it is running, new points have to be
  added to an existing curve. drawCurve can be used to display them avoiding
  a complete redraw of the canvas.

  Setting plot()->canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
  will result in faster painting, if the paint engine of the canvas widget
  supports this feature. 

  \param from Index of the first point to be painted
  \param to Index of the last point to be painted. If to < 0 the
         curve will be painted to its last point.

  \sa drawCurve(), drawSymbols()
*/
void QwtPlotCurve::draw(int from, int to) const
{
    if ( !plot() )
        return;

    QwtPlotCanvas *canvas = plot()->canvas();

#if QT_VERSION >= 0x040000
#if 0
    if ( canvas->paintEngine()->type() == QPaintEngine::OpenGL )
    {
        /*
            OpenGL alway repaint the complete widget.
            So for this operation OpenGL is one of the slowest
            environments.
         */
        canvas->repaint();
        return;
    }
#endif

    if ( !canvas->testAttribute(Qt::WA_WState_InPaintEvent)  /* &&
         !canvas->testAttribute(Qt::WA_PaintOutsidePaintEvent) */ )
    {
        /*
          We save curve and range in helper and call repaint.
          The helper filters the Paint event, to repeat
          the QwtPlotCurve::draw, but now from inside the paint
          event.
         */

        QwtPlotCurvePaintHelper helper(this, from, to);
        canvas->installEventFilter(&helper);

        const bool noSystemBackground =
            canvas->testAttribute(Qt::WA_NoSystemBackground);
        canvas->setAttribute(Qt::WA_NoSystemBackground, true);
        canvas->repaint();
        canvas->setAttribute(Qt::WA_NoSystemBackground, noSystemBackground);

        return;
    }
#endif

    const QwtScaleMap xMap = plot()->canvasMap(xAxis());
    const QwtScaleMap yMap = plot()->canvasMap(yAxis());

    if ( canvas->testPaintAttribute(QwtPlotCanvas::PaintCached) &&
        canvas->paintCache() && !canvas->paintCache()->isNull() )
    {
        QPainter cachePainter((QPixmap *)canvas->paintCache());
        cachePainter.translate(-canvas->contentsRect().x(),
            -canvas->contentsRect().y());

        draw(&cachePainter, xMap, yMap, from, to);
    }

#if QT_VERSION >= 0x040000
    if ( canvas->testAttribute(Qt::WA_WState_InPaintEvent) )
    {
        QPainter painter(canvas);

        painter.setClipping(true);
        painter.setClipRect(canvas->contentsRect());

        draw(&painter, xMap, yMap, from, to);
    }
    else
#endif
    {
        QPainter *painter = d_data->guardedPainter.begin(canvas);
        draw(painter, xMap, yMap, from, to);
    }
}
 vector<int> postorderTraversal(TreeNode* root){
     helper(root);
     return ret;
 }
Esempio n. 21
0
TEST(pthread, pthread_mutex_NORMAL_wakeup) {
  MutexWakeupHelper helper(PTHREAD_MUTEX_NORMAL);
  helper.test();
}
Esempio n. 22
0
 int maxDepth(TreeNode *root) {
     // write your code here
     return helper(root, 0);
 }
Esempio n. 23
0
TEST(pthread, pthread_mutex_RECURSIVE_wakeup) {
  MutexWakeupHelper helper(PTHREAD_MUTEX_RECURSIVE);
  helper.test();
}
Esempio n. 24
0
 vector<string> findStrobogrammatic(int n) {
     return helper(n, n);
 }
 bool isSubtree(TreeNode* s, TreeNode* t) {
     if(!s) return false;
     if(helper(s, t)) return true;
     return isSubtree(s->left, t) || isSubtree(s->right, t);
 }
 vector<int> preorderTraversal(TreeNode* root) {
     vector<int> res;
     helper(root, res);
     return res;
 }
Esempio n. 27
0
void
ChromiumCDMProxy::Init(PromiseId aPromiseId,
                       const nsAString& aOrigin,
                       const nsAString& aTopLevelOrigin,
                       const nsAString& aGMPName)
{
  MOZ_ASSERT(NS_IsMainThread());
  NS_ENSURE_TRUE_VOID(!mKeys.IsNull());

  EME_LOG(
    "ChromiumCDMProxy::Init (pid=%u, origin=%s, topLevelOrigin=%s, gmp=%s)",
    aPromiseId,
    NS_ConvertUTF16toUTF8(aOrigin).get(),
    NS_ConvertUTF16toUTF8(aTopLevelOrigin).get(),
    NS_ConvertUTF16toUTF8(aGMPName).get());

  if (!mGMPThread) {
    RejectPromise(
      aPromiseId,
      NS_ERROR_DOM_INVALID_STATE_ERR,
      NS_LITERAL_CSTRING("Couldn't get GMP thread ChromiumCDMProxy::Init"));
    return;
  }

  if (aGMPName.IsEmpty()) {
    RejectPromise(aPromiseId,
                  NS_ERROR_DOM_INVALID_STATE_ERR,
                  nsPrintfCString("Unknown GMP for keysystem '%s'",
                                  NS_ConvertUTF16toUTF8(mKeySystem).get()));
    return;
  }

  gmp::NodeId nodeId(aOrigin, aTopLevelOrigin, aGMPName);
  RefPtr<AbstractThread> thread = mGMPThread;
  RefPtr<GMPCrashHelper> helper(mCrashHelper);
  RefPtr<ChromiumCDMProxy> self(this);
  nsCString keySystem = NS_ConvertUTF16toUTF8(mKeySystem);
  RefPtr<Runnable> task(NS_NewRunnableFunction(
    [self, nodeId, helper, aPromiseId, thread, keySystem]() -> void {
      MOZ_ASSERT(self->IsOnOwnerThread());

      RefPtr<gmp::GeckoMediaPluginService> service =
        gmp::GeckoMediaPluginService::GetGeckoMediaPluginService();
      if (!service) {
        self->RejectPromise(
          aPromiseId,
          NS_ERROR_DOM_INVALID_STATE_ERR,
          NS_LITERAL_CSTRING(
            "Couldn't get GeckoMediaPluginService in ChromiumCDMProxy::Init"));
        return;
      }
      RefPtr<gmp::GetCDMParentPromise> promise =
        service->GetCDM(nodeId, { keySystem }, helper);
      promise->Then(
        thread,
        __func__,
        [self, aPromiseId](RefPtr<gmp::ChromiumCDMParent> cdm) {
          if (!cdm->Init(self,
                         self->mDistinctiveIdentifierRequired,
                         self->mPersistentStateRequired)) {
            self->RejectPromise(aPromiseId,
                                NS_ERROR_FAILURE,
                                NS_LITERAL_CSTRING("GetCDM failed."));
            return;
          }
          {
            MutexAutoLock lock(self->mCDMMutex);
            self->mCDM = cdm;
          }
          self->OnCDMCreated(aPromiseId);
        },
        [self, aPromiseId](nsresult rv) {
          self->RejectPromise(
            aPromiseId, NS_ERROR_FAILURE, NS_LITERAL_CSTRING("GetCDM failed."));
        });
    }));

  mGMPThread->Dispatch(task.forget());
}
 vector<int> inorderTraversal(TreeNode* root) {
     vector<int> result;
     helper(result, root);
     return result;
 }
 vector<vector<int> > zigzagLevelOrder(TreeNode *root) {
     vector<vector<int> > result;
     helper(root, 1, true, result);   // no need to set up a new bool, true is enough
     return result;  // don't forget to return
 }
Esempio n. 30
0
 static constexpr auto apply(Xs const& xs, Ys const& ys, Pred const& pred) {
     return helper(xs, ys, pred, hana::bool_c<
         decltype(hana::is_empty(xs))::value ||
         decltype(hana::is_empty(ys))::value
     >);
 }