It is important that this method is synchronised as there is some
interaction between the events and we need to ensure we process one at a
time.
428997
@Override
    synchronized public void onManagerEvent(final ManagerEvent event)
    {

        if (event instanceof HangupEvent)
        {
            final HangupEvent hangupEvt = (HangupEvent) event;
            final Channel hangupChannel = hangupEvt.getChannel();

            if (channelId.equals(hangupEvt.getUniqueId()))
            {
                this.originateSuccess = false;
                OriginateBaseClass.logger.warn("Dest channel " + this.newChannel + " hungup");
                originateLatch.countDown();
            }
            if ((this.monitorChannel1 != null) && (hangupChannel.isSame(this.monitorChannel1)))
            {
                this.originateSuccess = false;
                this.hungup = true;
                if (this.newChannel != null)
                {
                    OriginateBaseClass.logger.debug("hanging up " + this.newChannel);
                    this.result.setChannelHungup(true);

                    PBX pbx = PBXFactory.getActivePBX();
                    try
                    {
                        logger.warn("Hanging up");
                        pbx.hangup(this.newChannel);
                    }
                    catch (IllegalArgumentException | IllegalStateException | PBXException e)
                    {
                        logger.error(e, e);

                    }
                }
                OriginateBaseClass.logger.debug("notify channel 1 hungup");
                originateLatch.countDown();
            }
            if ((this.monitorChannel2 != null) && (hangupChannel.isSame(this.monitorChannel2)))
            {
                this.originateSuccess = false;
                this.hungup = true;
                if (this.newChannel != null)
                {
                    OriginateBaseClass.logger.debug("Hanging up channel " + this.newChannel);
                    this.result.setChannelHungup(true);

                    PBX pbx = PBXFactory.getActivePBX();
                    try
                    {
                        pbx.hangup(this.newChannel);
                    }
                    catch (IllegalArgumentException | IllegalStateException | PBXException e)
                    {
                        logger.error(e, e);

                    }
                }
                OriginateBaseClass.logger.debug("Notify channel 2 (" + this.monitorChannel2 + ") hungup");//$NON-NLS-2$
                originateLatch.countDown();
            }

        }
        if (event instanceof OriginateResponseEvent)
        {
            OriginateBaseClass.logger.debug("response : " + this.newChannel);

            final OriginateResponseEvent response = (OriginateResponseEvent) event;
            OriginateBaseClass.logger.debug("OriginateResponseEvent: channel="
                    + (response.isChannel() ? response.getChannel() : response.getEndPoint()) + " originateID:"
                    + this.originateID);
            OriginateBaseClass.logger.debug("{" + response.getReason() + ":" + response.getResponse() + "}"); //$NON-NLS-2$ //$NON-NLS-3$
            if (this.originateID != null)
            {
                if (this.originateID.compareToIgnoreCase(response.getActionId()) == 0)
                {
                    this.originateSuccess = response.isSuccess();
                    OriginateBaseClass.logger.debug("OriginateResponse: matched actionId, success=" + this.originateSuccess
                            + " channelSeen=" + this.channelSeen);

                    this.originateSeen = true;

                    if (originateSuccess)
                    {
                        if (newChannel == null)
                        {
                            this.newChannel = response.getChannel();
                        }
                        channelSeen = newChannel != null;

                        // if we have also seen the channel then we can notify
                        // the
                        // originate() method
                        // that the call is up. Otherwise we will rely on the
                        // NewChannelEvent doing the
                        // notify.
                        if (this.channelSeen == true)
                        {
                            OriginateBaseClass.logger.info("notify originate response event " + this.originateSuccess);
                            originateLatch.countDown();
                        }
                        else
                        {
                            logger.error("Originate Response didn't contain the channel");
                        }
                    }
                }
            }
            else
            {
                OriginateBaseClass.logger.warn("actionid is null");
            }
        }

        if (event instanceof NewChannelEvent)
        {
            final NewChannelEvent newState = (NewChannelEvent) event;
            if (channelId.equalsIgnoreCase(newState.getChannel().getUniqueId()))
            {
                final Channel channel = newState.getChannel();

                OriginateBaseClass.logger.debug("new channel event :" + channel + " context = " + newState.getContext() //$NON-NLS-2$
                        + " state =" + newState.getChannelStateDesc() + " state =" + newState.getChannelState()); //$NON-NLS-2$

                handleId(channel);
            }
        }

        if (event instanceof BridgeEvent)
        {
            if (((BridgeEvent) event).isLink())
            {
                final BridgeEvent bridgeEvent = (BridgeEvent) event;
                Channel channel = bridgeEvent.getChannel1();
                if (bridgeEvent.getChannel1().isLocal())
                {
                    channel = bridgeEvent.getChannel2();
                }
                if (channelId.equalsIgnoreCase(bridgeEvent.getChannel1().getUniqueId())
                        || channelId.equalsIgnoreCase(bridgeEvent.getChannel2().getUniqueId()))
                {

                    OriginateBaseClass.logger
                            .debug("new bridge event :" + channel + " channel1 = " + bridgeEvent.getChannel1() //$NON-NLS-2$
                                    + " channel2 =" + bridgeEvent.getChannel2());

                    handleId(channel);
                }
            }

        }

        if (event instanceof DialEndEvent)
        {
            if (channelId.equalsIgnoreCase(((DialEndEvent) event).getDestChannel().getUniqueId()))
            {
                String forward = ((DialEndEvent) event).getForward();
                if (forward != null && forward.length() > 0)
                {
                    originateLatch.countDown();
                }
            }
        }
    }
247770
public void syncHeaderToMain()
    {
        // Don't call super.
        this.syncContactTypeToMain();
        ReferenceField fldMain = (ReferenceField)this.getMainRecord().getField(MessageDetail.PERSON_ID);
        this.syncRecordToMainField(fldMain, null, DBParams.HEADER_OBJECT_ID);
    }
813810
function() {
        var srcEvent = this.srcEvent;
        srcEvent.preventManipulation && srcEvent.preventManipulation();
        srcEvent.preventDefault && srcEvent.preventDefault();
      }
1006393
function init() {
      var _this = this;

      this._shouldSyncFromOpts = true;
      this.on('update', function () {
        if (_this._shouldSyncFromOpts) _this.trigger('sync');
        _this._shouldSyncFromOpts = true;
      });
    }
213250
private boolean isReconciling() {
        AggregatorState currentState = this.state.get();
        return currentState == AggregatorState.ReconciliationNeeded
                || currentState == AggregatorState.Reconciling;
    }
847561
private void postProcessEmbedded(Map<String, String> embNametoUDTQuery,
            Map<String, List<String>> embNametoDependentList)
    {
        for (Map.Entry<String, List<String>> entry : embNametoDependentList.entrySet())
        {
            checkRelationAndExecuteQuery(entry.getKey(), embNametoDependentList, embNametoUDTQuery);
        }
    }
877986
public function onAfterWrite()
    {
        parent::onAfterWrite();

        if (!$this->getOwner()->Contact()->exists()) {
            $sync = Config::inst()->get(Contact::class, 'sync_fields');
            $contact = Contact::create();

            foreach ($sync as $field) {
                $contact->$field = $this->getOwner()->$field;
            }

            $contact->MemberID = $this->getOwner()->ID;
            $contact->write();
        } else {
            $this->getOwner()->syncToContact();
        }


    }
285295
public function syncAutomation()
    {
        if ($this->jobHasAlreadyBeenRun('ddg_automation_status')) {
            $this->helper->log('Skipping ddg_automation_status job run');
            return;
        }

        $this->automationFactory->create()->sync();
    }
368167
Observable<ChatResult> synchroniseStore() {
        if (isSynchronising.getAndSet(true)) {
            log.i("Synchronisation in progress.");
            return Observable.fromCallable(() -> new ChatResult(true, null));
        }
        log.i("Synchronising store.");
        return synchroniseConversations()
                .onErrorReturn(t -> new ChatResult(false, new ChatResult.Error(0, t)))
                .doOnNext(i -> {
                    if (i.isSuccessful()) {
                        log.i("Synchronisation successfully finished.");
                    } else {
                        log.e("Synchronisation finished with error. " + (i.getError() != null ? i.getError().getDetails() : ""));
                    }
                    isSynchronising.compareAndSet(true, false);
                });
    }
1351118
public void observeProcessValidations(@Observes @Before @ProcessValidations PhaseEvent event) {
        log.debug("After Process Validations event");
        performObservation(event, PhaseIdType.PROCESS_VALIDATIONS);
    }
988627
function () {
		if (!this.hasImportedEvents) {
			var point = this,
				options = merge(point.series.options.point, point.options),
				events = options.events,
				eventType;

			point.events = events;

			for (eventType in events) {
				addEvent(point, eventType, events[eventType]);
			}
			this.hasImportedEvents = true;

		}
	}
519533
public synchronized void synchronizeWith(UpdateSynchronizer newsync) {
    // LoggingUtil.warning("Synchronizing: " + sync + " " + newsync, new
    // Throwable());
    if(synchronizer == newsync) {
      LoggingUtil.warning("Double-synced to the same plot!", new Throwable());
      return;
    }
    if(synchronizer != null) {
      LoggingUtil.warning("Attempting to synchronize to more than one synchronizer.");
      return;
    }
    synchronizer = newsync;
    newsync.addUpdateRunner(this);
  }
1144676
private Observable<ChatResult> synchroniseConversations() {

        return checkState().flatMap(client -> client.service().messaging()
                .getConversations(false)
                .flatMap(result -> persistenceController.loadAllConversations()
                        .map(chatConversationBases -> compare(result.isSuccessful(), result.getResult(), chatConversationBases)))
                .flatMap(this::updateLocalConversationList)
                .flatMap(result -> lookForMissingEvents(client, result))
                .map(result -> new ChatResult(result.isSuccessful, null)));
    }
1280137
public function process()
    {
        parent::process();

        foreach ($this->columns as $column) {
            $column->process();
        }

        foreach ($this->spanning_columns as $column) {
            $column->process();
        }

        foreach ($this->extra_rows as $row) {
            $row->process();
        }

        // this is part of the old selection API
        if ($this->hasColumn('checkbox')) {
            $items = $this->getColumn('checkbox');
            $this->checked_items = $items->getItems();
        }
    }
796649
def on_records(self, records):
        
        handler = self.handlers.get("on_records")
        if callable(handler):
            handler(records)
858612
private void processNewEdge(int role, int b) {
        final RoleSet roleClosure = getRoleClosure(role);
        processRole(role, b);
        for (int s = roleClosure.first(); s >= 0; s = roleClosure.next(s + 1)) {
            if (s == role)
                continue;
            processRole(s, b);
        }
    }
301530
private void onSynchronization(Node node, EntityMetadata metadata)
    {
        DefaultTransactionResource resource = (DefaultTransactionResource) coordinator.getResource(metadata
                .getPersistenceUnit());
        if (enableFlush)
        {
            resource.onFlush();
        }
        else
        {
            resource.syncNode(node);
        }
    }