コード例 #1
0
        public virtual void TryProcessNext()
        {
            long currentTime = SystemUtil.GetRelativeTimeMillis();

            if (currentTime - lastProcessedTime.Get() > waitTime.GetTime())
            {
                lastProcessedTime.Set(SystemUtil.GetRelativeTimeMillis());
                V data;
                lock (cache) {
                    data = cache.RetrieveNext();
                }
                if (data != null)
                {
                    bool successful;
                    lock (processLock) {
                        successful = TryProcess(data);
                    }
                    if (successful)
                    {
                        OnSuccess(data);
                    }
                    else
                    {
                        lock (cache) {
                            cache.Put(data);
                        }
                        OnFailure(data);
                    }
                }
            }
        }
コード例 #2
0
        public virtual void TryProcessNextAsync(bool?daemon)
        {
            long currentTime = SystemUtil.GetRelativeTimeMillis();

            if (currentTime - lastProcessedTime.Get() > waitTime.GetTime())
            {
                Thread thread = new Thread(() => TryProcessNext());
                if (daemon != null)
                {
                    thread.IsBackground = (bool)daemon;
                }
                thread.Start();
            }
        }
コード例 #3
0
        public virtual void DeepNestingInlineBlocksTest01()
        {
            // TODO DEVSIX-1963
            String      name        = "deepNestingInlineBlocksTest01.pdf";
            String      outFileName = destinationFolder + name;
            String      cmpFileName = sourceFolder + "cmp_" + name;
            PdfDocument pdfDoc      = new PdfDocument(new PdfWriter(outFileName));
            Document    doc         = new Document(pdfDoc);

            Color[] colors = new Color[] { ColorConstants.BLUE, ColorConstants.RED, ColorConstants.LIGHT_GRAY, ColorConstants
                                           .ORANGE };
            int       w = 60;
            int       n = 6;
            Paragraph p = new Paragraph("hello world").SetWidth(w);

            for (int i = 0; i < n; ++i)
            {
                Paragraph currP = new Paragraph().SetWidth(i == 0 ? w * 1.1f * 3 : 450 + 5 * i);
                currP.Add(p).Add(p).Add(p).SetBorder(new DashedBorder(colors[i % colors.Length], 0.5f));
                p = currP;
            }
            long start = SystemUtil.GetRelativeTimeMillis();

            doc.Add(p);
            // 606 on local machine (including jvm warming up)
            System.Console.Out.WriteLine(SystemUtil.GetRelativeTimeMillis() - start);
            p = new Paragraph("hello world");
            for (int i = 0; i < n; ++i)
            {
                Paragraph currP = new Paragraph();
                currP.Add(p).Add(p).Add(p).SetBorder(new DashedBorder(colors[i % colors.Length], 0.5f));
                p = currP;
            }
            start = SystemUtil.GetRelativeTimeMillis();
            doc.Add(p);
            // 4656 on local machine
            System.Console.Out.WriteLine(SystemUtil.GetRelativeTimeMillis() - start);
            doc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             , "diff"));
        }