text:
#include "editor.h"

WINE_DEFAULT_DEBUG_CHANNEL(richedit);

static void destroy_undo_item( struct undo_item *undo )
{
    switch( undo->type )
    {
    case undo_insert_run:
        heap_free( undo->u.insert_run.str );
        ME_ReleaseStyle( undo->u.insert_run.style );
        break;
    case undo_split_para:
        ME_DestroyString( undo->u.split_para.eol_str );
        break;
    default:
        break;
    }

    heap_free( undo );
}

static void empty_redo_stack(ME_TextEditor *editor)
{
    struct undo_item *cursor, *cursor2;
    LIST_FOR_EACH_ENTRY_SAFE( cursor, cursor2, &editor->redo_stack, struct undo_item, entry )
    {
        list_remove( &cursor->entry );
        destroy_undo_item( cursor );
    }
}

void ME_EmptyUndoStack(ME_TextEditor *editor)
{
  struct undo_item *cursor, *cursor2;
  if (editor->nUndoMode == umIgnore)
    return;

  TRACE("Emptying undo stack\n");

  editor->nUndoStackSize = 0;

  LIST_FOR_EACH_ENTRY_SAFE( cursor, cursor2, &editor->undo_stack, struct undo_item, entry )
  {
      list_remove( &cursor->entry );
      destroy_undo_item( cursor );
  }

  empty_redo_stack( editor );
}

static struct undo_item *add_undo( ME_TextEditor *editor, enum undo_type type )
{
    struct undo_item *undo, *item;
    struct list *head;

    if (editor->nUndoMode == umIgnore) return NULL;
    if (editor->nUndoLimit == 0) return NULL;

    undo = heap_alloc( sizeof(*undo) );
    if (!undo) return NULL;
    undo->type = type;

    if (editor->nUndoMode == umAddToUndo || editor->nUndoMode == umAddBackToUndo)
    {

        head = list_head( &editor->undo_stack );
        if (head)
        {
            item = LIST_ENTRY( head, struct undo_item, entry );
            if (item->type == undo_potential_end_transaction)
                item->type = undo_end_transaction;
        }

        if (editor->nUndoMode == umAddToUndo)
            TRACE("Pushing id=%d to undo stack, deleting redo stack\n", type);
        else
            TRACE("Pushing id=%d to undo stack\n", type);

        list_add_head( &editor->undo_stack, &undo->entry );

        if (type == undo_end_transaction || type == undo_potential_end_transaction)
            editor->nUndoStackSize++;

        if (editor->nUndoStackSize > editor->nUndoLimit)
        {
            struct undo_item *cursor2;
            /* remove oldest undo from stack */
            LIST_FOR_EACH_ENTRY_SAFE_REV( item, cursor2, &editor->undo_stack, struct undo_item, entry )
            {
                BOOL done = (item->type == undo_end_transaction);
                list_remove( &item->entry );
                destroy_undo_item( item );
                if (done) break;
            }
            editor->nUndoStackSize--;
        }

        /* any new operation (not redo) clears the redo stack */
        if (editor->nUndoMode == umAddToUndo) empty_redo_stack( editor );
    }
    else if (editor->nUndoMode == umAddToRedo)
    {
        TRACE("Pushing id=%d to redo stack\n", type);
        list_add_head( &editor->redo_stack, &undo->entry );
    }

    return undo;
}

BOOL add_undo_insert_run( ME_TextEditor *editor, int pos, const WCHAR *str, int len, int flags, ME_Style *style )
{
    struct undo_item *undo = add_undo( editor, undo_insert_run );
    if (!undo) return FALSE;

    undo->u.insert_run.str = heap_alloc( (len + 1) * sizeof(WCHAR) );
    if (!undo->u.insert_run.str)
    {
        ME_EmptyUndoStack( editor );
        return FALSE;
    }
    memcpy( undo->u.insert_run.str, str, len * sizeof(WCHAR) );
    undo->u.insert_run.str[len] = 0;
    undo->u.insert_run.pos = pos;
    undo->u.insert_run.len = len;
    undo->u.insert_run.flags = flags;
    undo->u.insert_run.style = style;
    ME_AddRefStyle( style );
    return TRUE;
}

BOOL add_undo_set_para_fmt( ME_TextEditor *editor, const ME_Paragraph *para )
{
    struct undo_item *undo = add_undo( editor, undo_set_para_fmt );
    if (!undo) return FALSE;

    undo->u.set_para_fmt.pos = para->nCharOfs;
    undo->u.set_para_fmt.fmt = *para->pFmt;
    undo->u.set_para_fmt.border = para->border;

    return TRUE;
}

BOOL add_undo_set_char_fmt( ME_TextEditor *editor, int pos, int len, const CHARFORMAT2W *fmt )
{
    struct undo_item *undo = add_undo( editor, undo_set_char_fmt );
    if (!undo) return FALSE;

    undo->u.set_char_fmt.pos = pos;
    undo->u.set_char_fmt.len = len;
    undo->u.set_char_fmt.fmt = *fmt;

    return TRUE;
}

BOOL add_undo_join_paras( ME_TextEditor *editor, int pos )
{
    struct undo_item *undo = add_undo( editor, undo_join_paras );
    if (!undo) return FALSE;

    undo->u.join_paras.pos = pos;
    return TRUE;
}

BOOL add_undo_split_para( ME_TextEditor *editor, const ME_Paragraph *para, ME_String *eol_str, const ME_Cell *cell )
{
    struct undo_item *undo = add_undo( editor, undo_split_para );
    if (!undo) return FALSE;

    undo->u.split_para.pos = para->nCharOfs - eol_str->nLen;
    undo->u.split_para.eol_str = eol_str;
    undo->u.split_para.fmt = *para->pFmt;
    undo->u.split_para.border = para->border;
    undo->u.split_para.flags = para->prev_para->member.para.nFlags & ~MEPF_CELL;

    if (cell)
    {
        undo->u.split_para.cell_border = cell->border;
        undo->u.split_para.cell_right_boundary = cell->nRightBoundary;
    }
    return TRUE;
}

BOOL add_undo_delete_run( ME_TextEditor *editor, int pos, int len )
{
    struct undo_item *undo = add_undo( editor, undo_delete_run );
    if (!undo) return FALSE;

    undo->u.delete_run.pos = pos;
    undo->u.delete_run.len = len;

    return TRUE;
}

/**
 * Commits preceding changes into a transaction that can be undone together.
 *
 * This should be called after all the changes occur associated with an event
 * so that the group of changes can be undone atomically as a transaction.
 *
 * This will have no effect the undo mode is set to ignore changes, or if no
 * changes preceded calling this function before the last time it was called.
 *
 * This can also be used to conclude a coalescing transaction (used for grouping
 * typed characters).
 */
void ME_CommitUndo(ME_TextEditor *editor)
{
  struct undo_item *item;
  struct list *head;

  if (editor->nUndoMode == umIgnore)
    return;

  assert(editor->nUndoMode == umAddToUndo);

  /* no transactions, no need to commit */
  head = list_head( &editor->undo_stack );
  if (!head) return;

  /* no need to commit empty transactions */
  item = LIST_ENTRY( head, struct undo_item, entry );
  if (item->type == undo_end_transaction) return;

  if (item->type == undo_potential_end_transaction)
  {
      item->type = undo_end_transaction;
      return;
  }

  add_undo( editor, undo_end_transaction );
}

/**
 * Groups subsequent changes with previous ones for an undo if coalescing.
 *
 * Has no effect if the previous changes were followed by a ME_CommitUndo. This
 * function will only have an affect if the previous changes were followed by
 * a call to ME_CommitCoalescingUndo, which allows the transaction to be
 * continued.
 *
 * This allows multiple consecutively typed characters to be grouped together
 * to be undone by a single undo operation.
 */
void ME_ContinueCoalescingTransaction(ME_TextEditor *editor)
{
  struct undo_item *item;
  struct list *head;

  if (editor->nUndoMode == umIgnore)
    return;

  assert(editor->nUndoMode == umAddToUndo);

  head = list_head( &editor->undo_stack );
  if (!head) return;

  item = LIST_ENTRY( head, struct undo_item, entry );
  if (item->type == undo_potential_end_transaction)
  {
    list_remove( &item->entry );
    editor->nUndoStackSize--;
    destroy_undo_item( item );
  }
}

/**
 * Commits preceding changes into a undo transaction that can be expanded.
 *
 * This function allows the transaction to be reopened with
 * ME_ContinueCoalescingTransaction in order to continue the transaction.  If an
 * undo item is added to the undo stack as a result of a change without the
 * transaction being reopened, then the transaction will be ended, and the
 * changes will become a part of the next transaction.
 *
 * This is used to allow typed characters to be grouped together since each
 * typed character results in a single event, and each event adding undo items
 * must be committed.  Using this function as opposed to ME_CommitUndo allows
 * multiple events to be grouped, and undone together.
 */
void ME_CommitCoalescingUndo(ME_TextEditor *editor)
{
  struct undo_item *item;
  struct list *head;

  if (editor->nUndoMode == umIgnore)
    return;

  assert(editor->nUndoMode == umAddToUndo);

  head = list_head( &editor->undo_stack );
  if (!head) return;

  /* no need to commit empty transactions */
  item = LIST_ENTRY( head, struct undo_item, entry );
  if (item->type == undo_end_transaction ||
      item->type == undo_potential_end_transaction)
      return;

  add_undo( editor, undo_potential_end_transaction );
}

static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
{

  if (editor->nUndoMode == umIgnore)
    return;
  TRACE("Playing undo/redo item, id=%d\n", undo->type);

  switch(undo->type)
  {
  case undo_potential_end_transaction:
  case undo_end_transaction:
    assert(0);
  case undo_set_para_fmt:
  {
    ME_Cursor tmp;
    ME_DisplayItem *para;
    ME_CursorFromCharOfs(editor, undo->u.set_para_fmt.pos, &tmp);
    para = ME_FindItemBack(tmp.pRun, diParagraph);
    add_undo_set_para_fmt( editor, &para->member.para );
    *para->member.para.pFmt = undo->u.set_para_fmt.fmt;
    para->member.para.border = undo->u.set_para_fmt.border;
    break;
  }
  case undo_set_char_fmt:
  {
    ME_Cursor start, end;
    ME_CursorFromCharOfs(editor, undo->u.set_char_fmt.pos, &start);
    end = start;
    ME_MoveCursorChars(editor, &end, undo->u.set_char_fmt.len);
    ME_SetCharFormat(editor, &start, &end, &undo->u.set_char_fmt.fmt);
    break;
  }
  case undo_insert_run:
  {
    ME_Cursor tmp;
    ME_CursorFromCharOfs(editor, undo->u.insert_run.pos, &tmp);
    ME_InsertRunAtCursor(editor, &tmp, undo->u.insert_run.style,
                         undo->u.insert_run.str,
                         undo->u.insert_run.len,
                         undo->u.insert_run.flags);
    break;
  }
  case undo_delete_run:
  {
    ME_Cursor tmp;
    ME_CursorFromCharOfs(editor, undo->u.delete_run.pos, &tmp);
    ME_InternalDeleteText(editor, &tmp, undo->u.delete_run.len, TRUE);
    break;
  }
  case undo_join_paras:
  {
    ME_Cursor tmp;
    ME_CursorFromCharOfs(editor, undo->u.join_paras.pos, &tmp);
    ME_JoinParagraphs(editor, tmp.pPara, TRUE);
    break;
  }
  case undo_split_para:
  {
    ME_Cursor tmp;
    ME_DisplayItem *this_para, *new_para;
    BOOL bFixRowStart;
    int paraFlags = undo->u.split_para.flags & (MEPF_ROWSTART|MEPF_CELL|MEPF_ROWEND);
    ME_CursorFromCharOfs(editor, undo->u.split_para.pos, &tmp);
    if (tmp.nOffset)
      ME_SplitRunSimple(editor, &tmp);
    this_para = tmp.pPara;
    bFixRowStart = this_para->member.para.nFlags & MEPF_ROWSTART;
    if (bFixRowStart)
    {
      /* Re-insert the paragraph before the table, making sure the nFlag value
       * is correct. */
      this_para->member.para.nFlags &= ~MEPF_ROWSTART;
    }
    new_para = ME_SplitParagraph(editor, tmp.pRun, tmp.pRun->member.run.style,
                                 undo->u.split_para.eol_str->szData, undo->u.split_para.eol_str->nLen, paraFlags);
    if (bFixRowStart)
      new_para->member.para.nFlags |= MEPF_ROWSTART;
    *new_para->member.para.pFmt = undo->u.split_para.fmt;
    new_para->member.para.border = undo->u.split_para.border;
    if (paraFlags)
    {
      ME_DisplayItem *pCell = new_para->member.para.pCell;
      pCell->member.cell.nRightBoundary = undo->u.split_para.cell_right_boundary;
      pCell->member.cell.border = undo->u.split_para.cell_border;
    }
    break;
  }
  }
}

BOOL ME_Undo(ME_TextEditor *editor)
{
  ME_UndoMode nMode = editor->nUndoMode;
  struct list *head;
  struct undo_item *undo, *cursor2;

  if (editor->nUndoMode == umIgnore) return FALSE;
  assert(nMode == umAddToUndo || nMode == umIgnore);

  head = list_head( &editor->undo_stack );
  if (!head) return FALSE;

  /* watch out for uncommitted transactions ! */
  undo = LIST_ENTRY( head, struct undo_item, entry );
  assert(undo->type == undo_end_transaction
        || undo->type == undo_potential_end_transaction);

  editor->nUndoMode = umAddToRedo;

  list_remove( &undo->entry );
  destroy_undo_item( undo );

  LIST_FOR_EACH_ENTRY_SAFE( undo, cursor2, &editor->undo_stack, struct undo_item, entry )
  {
      if (undo->type == undo_end_transaction) break;
      ME_PlayUndoItem( editor, undo );
      list_remove( &undo->entry );
      destroy_undo_item( undo );
  }

  ME_MoveCursorFromTableRowStartParagraph(editor);
  add_undo( editor, undo_end_transaction );
  ME_CheckTablesForCorruption(editor);
  editor->nUndoStackSize--;
  editor->nUndoMode = nMode;
  ME_UpdateRepaint(editor, FALSE);
  return TRUE;
}

BOOL ME_Redo(ME_TextEditor *editor)
{
  ME_UndoMode nMode = editor->nUndoMode;
  struct list *head;
  struct undo_item *undo, *cursor2;

  assert(nMode == umAddToUndo || nMode == umIgnore);

  if (editor->nUndoMode == umIgnore) return FALSE;

  head = list_head( &editor->redo_stack );
  if (!head) return FALSE;

  /* watch out for uncommitted transactions ! */
  undo = LIST_ENTRY( head, struct undo_item, entry );
  assert( undo->type == undo_end_transaction );

  editor->nUndoMode = umAddBackToUndo;
  list_remove( &undo->entry );
  destroy_undo_item( undo );

  LIST_FOR_EACH_ENTRY_SAFE( undo, cursor2, &editor->redo_stack, struct undo_item, entry )
  {
      if (undo->type == undo_end_transaction) break;
      ME_PlayUndoItem( editor, undo );
      list_remove( &undo->entry );
      destroy_undo_item( undo );
  }
  ME_MoveCursorFromTableRowStartParagraph(editor);
  add_undo( editor, undo_end_transaction );
  ME_CheckTablesForCorruption(editor);
  editor->nUndoMode = nMode;
  ME_UpdateRepaint(editor, FALSE);
  return TRUE;
}


text:
package php4dvd;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.testng.*;
import org.testng.annotations.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class AddMovieTest extends TestBase {
  private boolean acceptNextAlert = true;
  private StringBuffer verificationErrors = new StringBuffer();

  @Test
  public void testAddMovie() throws Exception {
    for (int second = 0;; second++) {
    	if (second >= 60) fail("timeout");
    	try { if (isElementPresent(By.linkText("Add movie"))) break; } catch (Exception e) {}
    	Thread.sleep(1000);
    }

    driver.findElement(By.linkText("Add movie")).click();
    for (int second = 0;; second++) {
    	if (second >= 60) fail("timeout");
    	try { if (isElementPresent(By.xpath("//div[@class='addmovie']"))) break; } catch (Exception e) {}
    	Thread.sleep(1000);
    }

    driver.findElement(By.name("name")).clear();
    driver.findElement(By.name("name")).sendKeys("Selenium Java Movie 2015");
    driver.findElement(By.name("year")).clear();
    driver.findElement(By.name("year")).sendKeys("2215");
    driver.findElement(By.name("rating")).clear();
    driver.findElement(By.name("rating")).sendKeys("10");
    driver.findElement(By.id("own_no")).click();
    driver.findElement(By.id("submit")).click();
    for (int second = 0;; second++) {
    	if (second >= 60) fail("timeout");
    	try { if (isElementPresent(By.linkText("Remove"))) break; } catch (Exception e) {}
    	Thread.sleep(1000);
    }

  }

  private boolean isElementPresent(By by) {
    try {
      driver.findElement(by);
      return true;
    } catch (NoSuchElementException e) {
      return false;
    }
  }

  private String closeAlertAndGetItsText() {
    try {
      Alert alert = driver.switchTo().alert();
      String alertText = alert.getText();
      if (acceptNextAlert) {
        alert.accept();
      } else {
        alert.dismiss();
      }
      return alertText;
    } finally {
      acceptNextAlert = true;
    }
  }
}

redpajama_set_name: RedPajamaGithub


text:
layout: post
title: Updates to REST tax/get POST with 13.3. release
date: 2013-04-15 23:45
author: anya.stettler
comments: true
categories: [older]
product: avaTax
doctype: blog
---
Some long-awaited additional parameters have been added to the tax/get POST request with the recent 13.3 release. These parameters are now available on both development and production for all clients using the REST API. With this update, the REST API is now in full best-practice parity with our SOAP API. For more information, see the tax/get POST documentation.

PosLaneCode

Client

BusinessIdentificationNo

TaxOverride


text:
void AddTaskESEFlowQC(TString particleSpecies = "",
                      Int_t uptoWhichHarmonics = 5,
                      Bool_t isMC = kFALSE,
		      AliFlowEventCuts::refMultMethod gMultiplicityEstimator = AliFlowEventCuts::kVZERO,
                      UInt_t triggerSelectionString = AliVEvent::kINT7,
		      Bool_t gCutOnSphericity = kFALSE,
		      Double_t gMinSphericity = 0.0,
		      Double_t gMaxSphericity = 1.0,
		      Int_t gAODfilterBit = 768,
                      Double_t gProbPID = 0.9,
		      Double_t gCharge = 0,
                      Bool_t doQA = kTRUE) {
  //======================================================================//
  // FLOW cut objects config
  const int nHarmonics = uptoWhichHarmonics - 1;
  AliFlowEventCuts* cutsEvent;
  AliFlowTrackCuts* cutsRP;
  AliFlowTrackCuts* cutsPOI;
  TString suffixName;
  TString outputSlotName[nHarmonics];

  //Create the event cut object
  cutsEvent = createFlowEventCutObject(gMultiplicityEstimator,gCutOnSphericity,gMinSphericity,gMaxSphericity,doQA);

  //Create the RP cut object
  cutsRP = createFlowRPCutObject(gAODfilterBit,gCharge,doQA);

  //Create the POI cut object
  cutsPOI = createFlowPOICutObject(particleSpecies,gAODfilterBit,gProbPID,gCharge,doQA);

  suffixName += "QC";
  if(particleSpecies != "") {
    suffixName += "_";
    suffixName += particleSpecies.Data();
    suffixName += "_";
  }
  else {
    suffixName += "_AllCharged";
    suffixName = Form("%s_%i",suffixName.Data(),gAODfilterBit);
    if(gCutOnSphericity)
      suffixName = Form("%s_%.1f_%.1f",suffixName.Data(),gMinSphericity,gMaxSphericity);
  }

  //=====================================================================
  for(int nHarmonic = 2; nHarmonic <= uptoWhichHarmonics; nHarmonic++)
    outputSlotName[nHarmonic - 2] = Form("%s_v%d",suffixName.Data(),nHarmonic);

  TString fileName = "AnalysisResults";
  fileName.Append(".root");

  //========================FLOWPACKAGE TASKS=========================//
  AliAnalysisDataContainer *cinput1;
  AliAnalysisDataContainer *coutputFE;
  AliAnalysisDataContainer *coutputFEQA;
  AliAnalysisTaskFlowEvent *taskFE;

  AliAnalysisDataContainer *flowEvent[nHarmonics];
  AliAnalysisTaskFilterFE *tskFilter[nHarmonics];

  AliAnalysisDataContainer *coutputQC[nHarmonics];
  AliAnalysisTaskQCumulants *taskQC[nHarmonics];

  TString outputQA;
  TString slot[nHarmonics];

  //Create the analysis manager
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    Error("AddTaskFlowEvent", "No analysis manager to connect to.");
    return NULL;
  }

  //Check the analysis type using the event handlers connected to the analysis
  // manager. The availability of MC handler can also be checked here.
  if (!mgr->GetInputEventHandler()) {
    ::Error("AddTaskFlowEvent", "This task requires an input event handler");
    return NULL;
  }

  taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent_%s",suffixName.Data()),"",doQA);
  taskFE->SelectCollisionCandidates(triggerSelectionString);

  mgr->AddTask(taskFE);

  // Pass cuts for RPs and POIs to the task:
  taskFE->SetCutsEvent(cutsEvent);
  taskFE->SetCutsRP(cutsRP);
  taskFE->SetCutsPOI(cutsPOI);
  if (cutsRP->GetParamType()==AliFlowTrackCuts::kVZERO) {
    taskFE->SetHistWeightvsPhiMin(0.);
    taskFE->SetHistWeightvsPhiMax(200.);
  }

  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  cinput1 = mgr->GetCommonInputContainer();

  coutputFE = mgr->CreateContainer(Form("FlowEvent_%s",suffixName.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);

  mgr->ConnectInput(taskFE,0,cinput1);
  mgr->ConnectOutput(taskFE,1,coutputFE);
  //==========================================================

  for(int nHarmonic = 2; nHarmonic <= uptoWhichHarmonics; nHarmonic++){
    flowEvent[nHarmonic-2] = mgr->CreateContainer(Form("Filter_%s",outputSlotName[nHarmonic-2].Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
    tskFilter[nHarmonic-2] = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s",outputSlotName[nHarmonic-2].Data()),cutsRP, NULL);

    mgr->AddTask(tskFilter[nHarmonic-2]);
    mgr->ConnectInput( tskFilter[nHarmonic-2],0,coutputFE);
    mgr->ConnectOutput(tskFilter[nHarmonic-2],1,flowEvent[nHarmonic-2]);

    //QC task
    taskQC[nHarmonic-2] = new AliAnalysisTaskQCumulants(Form("TaskQCumulants_%s",outputSlotName[nHarmonic-2].Data()),kFALSE);
    taskQC[nHarmonic-2]->SetHarmonic(nHarmonic);
    taskQC[nHarmonic-2]->SelectCollisionCandidates(triggerSelectionString);
    taskQC[nHarmonic-2]->SetApplyCorrectionForNUA(kTRUE);
    taskQC[nHarmonic-2]->SetMaxCommonResultsHistogram(8);
    taskQC[nHarmonic-2]->SetFillMultipleControlHistograms(kTRUE);
    taskQC[nHarmonic-2]->SetCalculateCumulantsVsM(kTRUE);
    taskQC[nHarmonic-2]->SetCalculateAllCorrelationsVsM(kTRUE);
    taskQC[nHarmonic-2]->SetFillProfilesVsMUsingWeights(kTRUE);
    taskQC[nHarmonic-2]->SetMinMult(0);
    taskQC[nHarmonic-2]->SetMaxMult(500);
    taskQC[nHarmonic-2]->SetnBinsMult(500);

    TString outputQC = fileName;
    outputQC += ":outputQCanalysis";

    coutputQC[nHarmonic-2] = mgr->CreateContainer(Form("%s",outputSlotName[nHarmonic-2].Data()),TList::Class(),AliAnalysisManager::kOutputContainer,outputQC);

    mgr->AddTask(taskQC[nHarmonic-2]);

    mgr->ConnectInput(taskQC[nHarmonic-2],0,flowEvent[nHarmonic-2]);
    mgr->ConnectInput(taskQC[nHarmonic-2],0,coutputFE);
    mgr->ConnectOutput(taskQC[nHarmonic-2],1,coutputQC[nHarmonic-2]);
  }//loop over the harmonics

  if (taskFE->GetQAOn()) {
    outputQA = fileName;
    outputQA += ":QA";
    coutputFEQA = mgr->CreateContainer(Form("QA_%s",suffixName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA);
    mgr->ConnectOutput(taskFE,2,coutputFEQA);
  }
}

//_________________________________________________________//
AliFlowEventCuts *createFlowEventCutObject(AliFlowEventCuts::refMultMethod gMultiplicityEstimator = AliFlowEventCuts::kVZERO, Bool_t gCutOnSphericity = kFALSE, Double_t gMinSphericity = 0.0, Double_t gMaxSphericity = 1.0, Bool_t doQA = kFALSE) {
  //Part of the code that creates the event cut objects
  Double_t gVertexZmin = -10., gVertexZmax = 10.;

  //Create the event cut objects
  AliFlowEventCuts *cutsEvent = new AliFlowEventCuts("eventcuts");
  cutsEvent->SetCentralityPercentileMethod(gMultiplicityEstimator);
  //cutsEvent->SetCutTPCmultiplicityOutliersAOD(kTRUE);
  cutsEvent->SetCheckPileup(kTRUE);
  cutsEvent->SetPrimaryVertexZrange(gVertexZmin,gVertexZmax);
  if(gCutOnSphericity)
    cutsEvent->SetSphericityCut(gMinSphericity,gMaxSphericity);
  cutsEvent->SetQA(doQA);

  //return the object
  return cutsEvent;
}

//_________________________________________________________//
AliFlowTrackCuts *createFlowRPCutObject(Int_t gAODfilterBit = 768,
                                        Double_t gCharge = 0.,
                                        Bool_t doQA = kFALSE) {
  //Part of the code that creates the RP cut objects
  Double_t gEtaMin = -0.8, gEtaMax = 0.8;
  Int_t gMinTPCdedx = 10;

  //Create the event cut objects
  AliFlowTrackCuts *cutsRP = new AliFlowTrackCuts("rpCuts");

  if (gCharge!=0) cutsRP->SetCharge(gCharge);

  cutsRP->SetMinNClustersTPC(70);
  cutsRP->SetPtRange(0.2,10.);
  cutsRP->SetEtaRange(gEtaMin,gEtaMax);
  cutsRP->SetMinimalTPCdedx(gMinTPCdedx);
  cutsRP->SetAODfilterBit(gAODfilterBit);
  cutsRP->SetQA(doQA);

  //return the object
  return cutsRP;
}

//_________________________________________________________//
AliFlowTrackCuts *createFlowPOICutObject(TString particleSpecies = "Pion",
					 Int_t gAODfilterBit = 768,
                                         Double_t gProbPID = 0.9,
					 Double_t gCharge = 0.,
                                         Bool_t doQA = kFALSE) {
  //Part of the code that creates the POI cut objects
  Double_t gEtaMin = -0.8, gEtaMax = 0.8;
  Int_t gMinTPCdedx = 10;

  AliFlowTrackCuts *cutsPOI = new AliFlowTrackCuts("poiCuts");

  if (gCharge!=0) cutsPOI->SetCharge(gCharge);

  cutsPOI->SetMinNClustersTPC(70);
  cutsPOI->SetPtRange(0.2,10.);
  cutsPOI->SetEtaRange(gEtaMin,gEtaMax);
  cutsPOI->SetMinimalTPCdedx(gMinTPCdedx);
  cutsPOI->SetAODfilterBit(gAODfilterBit);
  cutsPOI->SetQA(doQA);

  Bool_t isPID = kFALSE;
  if(particleSpecies != "")
    isPID = kTRUE;

  if(isPID) {
    AliFlowTrackCuts::PIDsource sourcePID=AliFlowTrackCuts::kTOFbayesian;
    AliPID::EParticleType particleType = AliPID::kPion;

    if(particleSpecies.Contains("Pion")) {
      particleType = AliPID::kPion;
    }
    else if(particleSpecies.Contains("Kaon")) {
      particleType = AliPID::kKaon;
    }
    else if(particleSpecies.Contains("Proton")) {
      particleType = AliPID::kProton;
    }

    cutsPOI->SetPID(particleType, sourcePID, gProbPID);
  }

  //return the object
  return cutsPOI;
}


text:
package ldap

import (
	"crypto/tls"
	"errors"
	"fmt"
	"log"
	"net"
	"sync"

	"gopkg.in/asn1-ber.v1"
)

const (
	MessageQuit     = 0
	MessageRequest  = 1
	MessageResponse = 2
	MessageFinish   = 3
)

type messagePacket struct {
	Op        int
	MessageID int64
	Packet    *ber.Packet
	Channel   chan *ber.Packet
}

type sendMessageFlags uint

const (
	startTLS sendMessageFlags = 1 << iota
)

// Conn represents an LDAP Connection
type Conn struct {
	conn                net.Conn
	isTLS               bool
	isClosing           bool
	isStartingTLS       bool
	Debug               debugging
	chanConfirm         chan bool
	chanResults         map[int64]chan *ber.Packet
	chanMessage         chan *messagePacket
	chanMessageID       chan int64
	wgSender            sync.WaitGroup
	wgClose             sync.WaitGroup
	once                sync.Once
	outstandingRequests uint
	messageMutex        sync.Mutex
}

// Dial connects to the given address on the given network using net.Dial
// and then returns a new Conn for the connection.
func Dial(network, addr string) (*Conn, error) {
	c, err := net.Dial(network, addr)
	if err != nil {
		return nil, NewError(ErrorNetwork, err)
	}
	conn := NewConn(c)
	conn.start()
	return conn, nil
}

// DialTLS connects to the given address on the given network using tls.Dial
// and then returns a new Conn for the connection.
func DialTLS(network, addr string, config *tls.Config) (*Conn, error) {
	c, err := tls.Dial(network, addr, config)
	if err != nil {
		return nil, NewError(ErrorNetwork, err)
	}
	conn := NewConn(c)
	conn.isTLS = true
	conn.start()
	return conn, nil
}

// NewConn returns a new Conn using conn for network I/O.
func NewConn(conn net.Conn) *Conn {
	return &Conn{
		conn:          conn,
		chanConfirm:   make(chan bool),
		chanMessageID: make(chan int64),
		chanMessage:   make(chan *messagePacket, 10),
		chanResults:   map[int64]chan *ber.Packet{},
	}
}

func (l* Conn) IsOpen() bool {
	return !l.isClosing
}

func (l *Conn) start() {
	go l.reader()
	go l.processMessages()
	l.wgClose.Add(1)
}

// Close closes the connection.
func (l *Conn) Close() {
	l.once.Do(func() {
		l.isClosing = true
		l.wgSender.Wait()

		l.Debug.Printf("Sending quit message and waiting for confirmation")
		l.chanMessage <- &messagePacket{Op: MessageQuit}
		<-l.chanConfirm
		close(l.chanMessage)

		l.Debug.Printf("Closing network connection")
		if err := l.conn.Close(); err != nil {
			log.Print(err)
		}

		l.wgClose.Done()
	})
	l.wgClose.Wait()
}

// Returns the next available messageID
func (l *Conn) nextMessageID() int64 {
	if l.chanMessageID != nil {
		if messageID, ok := <-l.chanMessageID; ok {
			return messageID
		}
	}
	return 0
}

// StartTLS sends the command to start a TLS session and then creates a new TLS Client
func (l *Conn) StartTLS(config *tls.Config) error {
	messageID := l.nextMessageID()

	if l.isTLS {
		return NewError(ErrorNetwork, errors.New("ldap: already encrypted"))
	}

	packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
	packet.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, messageID, "MessageID"))
	request := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationExtendedRequest, nil, "Start TLS")
	request.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, 0, "1.3.6.1.4.1.1466.20037", "TLS Extended Command"))
	packet.AppendChild(request)
	l.Debug.PrintPacket(packet)

	channel, err := l.sendMessageWithFlags(packet, startTLS)
	if err != nil {
		return err
	}
	if channel == nil {
		return NewError(ErrorNetwork, errors.New("ldap: could not send message"))
	}

	l.Debug.Printf("%d: waiting for response", messageID)
	packet = <-channel
	l.Debug.Printf("%d: got response %p", messageID, packet)
	l.finishMessage(messageID)

	if l.Debug {
		if err := addLDAPDescriptions(packet); err != nil {
			l.Close()
			return err
		}
		ber.PrintPacket(packet)
	}

	if packet.Children[1].Children[0].Value.(int64) == 0 {
		conn := tls.Client(l.conn, config)

		if err := conn.Handshake(); err != nil {
			l.Close()
			return NewError(ErrorNetwork, fmt.Errorf("TLS handshake failed (%v)", err))
		}

		l.isTLS = true
		l.conn = conn
	}
	go l.reader()

	return nil
}

func (l *Conn) sendMessage(packet *ber.Packet) (chan *ber.Packet, error) {
	return l.sendMessageWithFlags(packet, 0)
}

func (l *Conn) sendMessageWithFlags(packet *ber.Packet, flags sendMessageFlags) (chan *ber.Packet, error) {
	if l.isClosing {
		return nil, NewError(ErrorNetwork, errors.New("ldap: connection closed"))
	}
	l.messageMutex.Lock()
	l.Debug.Printf("flags&startTLS = %d", flags&startTLS)
	if l.isStartingTLS {
		l.messageMutex.Unlock()
		return nil, NewError(ErrorNetwork, errors.New("ldap: connection is in startls phase."))
	}
	if flags&startTLS != 0 {
		if l.outstandingRequests != 0 {
			l.messageMutex.Unlock()
			return nil, NewError(ErrorNetwork, errors.New("ldap: cannot StartTLS with outstanding requests"))
		} else {
			l.isStartingTLS = true
		}
	}
	l.outstandingRequests++

	l.messageMutex.Unlock()

	out := make(chan *ber.Packet)
	message := &messagePacket{
		Op:        MessageRequest,
		MessageID: packet.Children[0].Value.(int64),
		Packet:    packet,
		Channel:   out,
	}
	l.sendProcessMessage(message)
	return out, nil
}

func (l *Conn) finishMessage(messageID int64) {
	if l.isClosing {
		return
	}

	l.messageMutex.Lock()
	l.outstandingRequests--
	if l.isStartingTLS {
		l.isStartingTLS = false
	}
	l.messageMutex.Unlock()

	message := &messagePacket{
		Op:        MessageFinish,
		MessageID: messageID,
	}
	l.sendProcessMessage(message)
}

func (l *Conn) sendProcessMessage(message *messagePacket) bool {
	if l.isClosing {
		return false
	}
	l.wgSender.Add(1)
	l.chanMessage <- message
	l.wgSender.Done()
	return true
}

func (l *Conn) processMessages() {
	defer func() {
		if err := recover(); err != nil {
			log.Printf("ldap: recovered panic in processMessages: %v", err)
		}
		for messageID, channel := range l.chanResults {
			l.Debug.Printf("Closing channel for MessageID %d", messageID)
			close(channel)
			delete(l.chanResults, messageID)
		}
		close(l.chanMessageID)
		l.chanConfirm <- true
		close(l.chanConfirm)
	}()

	var messageID int64 = 1
	for {
		select {
		case l.chanMessageID <- messageID:
			messageID++
		case messagePacket, ok := <-l.chanMessage:
			if !ok {
				l.Debug.Printf("Shutting down - message channel is closed")
				return
			}
			switch messagePacket.Op {
			case MessageQuit:
				l.Debug.Printf("Shutting down - quit message received")
				return
			case MessageRequest:
				// Add to message list and write to network
				l.Debug.Printf("Sending message %d", messagePacket.MessageID)
				l.chanResults[messagePacket.MessageID] = messagePacket.Channel
				// go routine
				buf := messagePacket.Packet.Bytes()

				_, err := l.conn.Write(buf)
				if err != nil {
					l.Debug.Printf("Error Sending Message: %s", err.Error())
					break
				}
			case MessageResponse:
				l.Debug.Printf("Receiving message %d", messagePacket.MessageID)
				if chanResult, ok := l.chanResults[messagePacket.MessageID]; ok {
					chanResult <- messagePacket.Packet
				} else {
					log.Printf("Received unexpected message %d", messagePacket.MessageID)
					ber.PrintPacket(messagePacket.Packet)
				}
			case MessageFinish:
				// Remove from message list
				l.Debug.Printf("Finished message %d", messagePacket.MessageID)
				close(l.chanResults[messagePacket.MessageID])
				delete(l.chanResults, messagePacket.MessageID)
			}
		}
	}
}

func (l *Conn) reader() {
	cleanstop := false
	defer func() {
		if err := recover(); err != nil {
			log.Printf("ldap: recovered panic in reader: %v", err)
		}
		if !cleanstop {
			l.Close()
		}
	}()

	for {
		if cleanstop {
			l.Debug.Printf("reader clean stopping (without closing the connection)")
			return
		}
		packet, err := ber.ReadPacket(l.conn)
		if err != nil {
			// A read error is expected here if we are closing the connection...
			if !l.isClosing {
				l.Debug.Printf("reader error: %s", err.Error())
			}
			return
		}
		addLDAPDescriptions(packet)
		if len(packet.Children) == 0 {
			l.Debug.Printf("Received bad ldap packet")
			continue
		}
		l.messageMutex.Lock()
		if l.isStartingTLS {
			cleanstop = true
		}
		l.messageMutex.Unlock()
		message := &messagePacket{
			Op:        MessageResponse,
			MessageID: packet.Children[0].Value.(int64),
			Packet:    packet,
		}
		if !l.sendProcessMessage(message) {
			return
		}

	}
}


text:
OpenCensus Trace: Bug 001: Attributes incorrect GC count yields garbage data.
--FILE--
<?php

function myEcho ($var) {
    echo $var . PHP_EOL;
}

function execute() {
    $str = "Hello World!";
    myEcho($str);
}

function allocate_strings($count) {
    $foo = "asdf";
    for ($i = 0; $i < $count; $i++) {
        $foo .= ",$i";
    }
}

function inspect() {
    $span = opencensus_trace_list()[0];
    print_r($span->attributes());
}

// 1: Sanity test a simple profile run
opencensus_trace_function("myEcho", function ($x) {
    return ['name' => 'foo', 'startTime' => 0.1, 'attributes' => ['text' => $x]];
});

execute();
execute();

inspect();
inspect();

?>
--EXPECT--
Hello World!
Hello World!
Array
(
    [text] => Hello World!
)
Array
(
    [text] => Hello World!
)