Only call with monitor for 'this' held
358338
private void map(Resource root) {

        for (Resource.ResourceEntry serverGroup : root.getChildren(SERVER_GROUP)) {
            String serverGroupName = serverGroup.getName();
            ModelNode serverGroupModel = serverGroup.getModel();
            String profile = serverGroupModel.require(PROFILE).asString();
            store(serverGroupName, profile, profilesToGroups);
            String socketBindingGroup = serverGroupModel.require(SOCKET_BINDING_GROUP).asString();
            store(serverGroupName, socketBindingGroup, socketsToGroups);

            for (Resource.ResourceEntry deployment : serverGroup.getChildren(DEPLOYMENT)) {
                store(serverGroupName, deployment.getName(), deploymentsToGroups);
            }

            for (Resource.ResourceEntry overlay : serverGroup.getChildren(DEPLOYMENT_OVERLAY)) {
                store(serverGroupName, overlay.getName(), overlaysToGroups);
            }

        }

        for (Resource.ResourceEntry host : root.getChildren(HOST)) {
            String hostName = host.getPathElement().getValue();
            for (Resource.ResourceEntry serverConfig : host.getChildren(SERVER_CONFIG)) {
                ModelNode serverConfigModel = serverConfig.getModel();
                String serverGroupName = serverConfigModel.require(GROUP).asString();
                store(serverGroupName, hostName, hostsToGroups);
            }
        }
    }
330512
final Operation setCallTimeout(long callTimeout) {
        this.callTimeout = callTimeout;
        setFlag(callTimeout > Integer.MAX_VALUE, BITMASK_CALL_TIMEOUT_64_BIT);
        return this;
    }
187470
def monitor(name, callback):
    '''
     
    '''
    global _monitor 
    if not exists(name):
        raise ContainerNotExists("The container (%s) does not exist!" % name)
    if _monitor:
        if _monitor.is_monitored(name):
            raise Exception("You are already monitoring this container (%s)" % name)
    else:
        _monitor = _LXCMonitor()
        logging.info("Starting LXC Monitor")
        _monitor.start()
        def kill_handler(sg, fr):
            stop_monitor()
        signal.signal(signal.SIGTERM, kill_handler)
        signal.signal(signal.SIGINT, kill_handler)
    _monitor.add_monitor(name, callback)
93922
@Override protected synchronized Object doInBackground() throws Exception {
        try {
            setProgress(INITIALIZING);

            // perform initialization of camera device
            // access FrameGrabber objects from _this_ thread *ONLY*...
            frameGrabber = cameraDevice.createFrameGrabber();
            frameGrabber.setImageMode(ImageMode.COLOR);
            if (trackingSettings.useOpenCL) {
                frameGrabber.setPixelFormat(AV_PIX_FMT_RGBA);
            }
            frameGrabber.start();
            grabberConverter = new OpenCVFrameConverter.ToIplImage();
            IplImage image = grabberConverter.convert(frameGrabber.grab());
            final IplImage initImage = image;
            final int initWidth    = initImage.width();
            final int initHeight   = initImage.height();
            final int initChannels = trackingSettings.useOpenCL ? 4 : initImage.nChannels();
            final int initDepth    = initImage.depth();

            if (initWidth != cameraDevice.imageWidth || initHeight != cameraDevice.imageHeight) {
                cameraDevice.rescale(initWidth, initHeight);
            }

            // resize and tile the monitor frames according to the size of the grabbed images
            if (monitorWindows != null) {
                final double initScale = trackingSettings.getMonitorWindowsScale();
                EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        for (int i = 0; i < monitorWindows.length; i++) {
                            monitorWindows[i].setCanvasSize(
                                    (int)Math.round(initWidth *initScale),
                                    (int)Math.round(initHeight*initScale));
                            monitorWindows[i].setTitle(monitorWindowsTitles[i] + " (" +
                                    initWidth + " x " + initHeight + "  " +
                                    (initDepth&~IPL_DEPTH_SIGN) + " bpp  gamma = " +
                                    frameGrabber.getGamma() + ") - ProCamTracker");
                        }
                    }
                });
                CanvasFrame.tile(monitorWindows);
                CanvasFrame.global = monitorWindows[0];
            }

            // allocate memory for all images and load video
            final int minLevel = alignerSettings.getPyramidLevelMin();
            undistortedCameraImage  = IplImage.create(initWidth >> minLevel,
                    initHeight >> minLevel, initDepth, initChannels);
            distortedProjectorImage = IplImage.create(projectorDevice.imageWidth,
                    projectorDevice.imageHeight, IPL_DEPTH_8U, initChannels);
            BufferRing.BufferFactory<ProjectorBuffer> projectorBufferFactory;
            projectorBufferFactory = new BufferRing.BufferFactory<ProjectorBuffer>() {
                public ProjectorBuffer create() {
                    return new ProjectorBuffer(distortedProjectorImage, false);
                }
            };
            if (trackingSettings.useOpenCL) {
                GLContext shareWith = null;
                if (projectorFrame instanceof GLCanvasFrame) {
                    shareWith = ((GLCanvasFrame)projectorFrame).getGLCanvas().getContext();
                }
                contextCL = new JavaCVCL(shareWith);

                grabbedImageCL            = //contextCL.createCLImageFrom(initImage);
                        contextCL.getCLContext().createImage2d(initWidth, initHeight,
                                new CLImageFormat(frameGrabber.getSensorPattern() != -1L ?
                                        CLImageFormat.ChannelOrder.R :
                                        CLImageFormat.ChannelOrder.RGBA, ChannelType.UNORM_INT8));
                undistortedCameraImageCL  = //contextCL.createCLImageFrom(undistortedCameraImage);
                        contextCL.getCLContext().createImage2d(
                                undistortedCameraImage.width(), undistortedCameraImage.height(),
                                new CLImageFormat(CLImageFormat.ChannelOrder.RGBA, ChannelType.FLOAT));
                cameraDevice.setMapsPyramidLevel(minLevel);
                cameraMapxCL = contextCL.writeImage(cameraMapxCL, cameraDevice.getUndistortMap1(), false);
                cameraMapyCL = contextCL.writeImage(cameraMapyCL, cameraDevice.getUndistortMap2(), false);

                if (projectorFrame != null) {
                    projectorMapxCL = contextCL.writeImage(projectorMapxCL, projectorDevice.getDistortMap1(), false);
                    projectorMapyCL = contextCL.writeImage(projectorMapyCL, projectorDevice.getDistortMap2(), false);
                    distortedProjectorImageCL = contextCL.createCLGLImageFrom(distortedProjectorImage);
                }
                projectorBufferFactory = new BufferRing.BufferFactory<ProjectorBuffer>() {
                    public ProjectorBuffer create() {
                        return new ProjectorBuffer(distortedProjectorImage, true);
                    }
                };
            }
            projectorBufferRing = new BufferRing<ProjectorBuffer>(projectorBufferFactory,
                    trackingSettings.projectorBufferingSize);

            realityAugmentor = new RealityAugmentor(realityAugmentorSettings,
                    objectFinderSettings, markerDetectorSettings, virtualBallSettings,
                    cameraDevice, projectorDevice, initChannels);

            handMouse = new HandMouse(handMouseSettings);

            // get the three projector frames for initialization
            GNImageAligner.Settings s = alignerSettings.clone();
            // prepare settings for maximum accuracy
            s.setAlphaTikhonov(0);
            s.setDeltaMin(0);
            s.setLineSearch(new double[] { 1.0, 1.0/2, 1.0/4, 1.0/8, 1.0/16, 1.0/32, 1.0/64, 1.0/128 });
            s.setThresholdsOutlier(new double[] { 0.0 });
            s.setThresholdsZero(new double[] { 0.0 });
            reflectanceInitializer = new ReflectanceInitializer(cameraDevice, projectorDevice, initChannels, s);
            projectorInitFloatImages = reflectanceInitializer.getProjectorImages();
            projectorInitImages   = new IplImage[projectorInitFloatImages.length];
            cameraInitImages      = new IplImage[projectorInitFloatImages.length];
            cameraInitFloatImages = new IplImage[projectorInitFloatImages.length];
            for (int i = 0; i < projectorInitFloatImages.length; i++) {
                projectorInitImages[i]   = IplImage.createCompatible(distortedProjectorImage);
                cameraInitImages[i]      = IplImage.create(initWidth, initHeight, initDepth, initChannels);
                cameraInitFloatImages[i] = IplImage.create(undistortedCameraImage.width(),
                        undistortedCameraImage.height(), IPL_DEPTH_32F, initChannels);
                cvConvertScale(projectorInitFloatImages[i], projectorInitImages[i], 255, 0);
                projectorDevice.distort(projectorInitImages[i], distortedProjectorImage);
                cvCopy(distortedProjectorImage, projectorInitImages[i]);
            }
            reflectanceImage = IplImage.createCompatible(cameraInitFloatImages[0]);
            if (trackingSettings.useOpenCL) {
                reflectanceImageCL = contextCL.createCLImageFrom(reflectanceImage);
            }

            if (trackingSettings.outputVideoFile != null) {
                frameRecorder = new FFmpegFrameRecorder(trackingSettings.outputVideoFile,
                        undistortedCameraImage.width(), undistortedCameraImage.height());
                frameRecorder.start();
                recorderConverter = new OpenCVFrameConverter.ToIplImage();
            } else {
                frameRecorder = null;
                recorderConverter = null;
            }

            boolean done = false;
            while (!done) {
                done = doTracking();

                // force release of native memory
                System.gc();
                Pointer.deallocateReferences();
            }
        } catch (Throwable t) {
            if (!isCancelled()) {
                while (t.getCause() != null) { t = t.getCause(); }
                logger.log(Level.SEVERE, "Could not perform tracking.", t);
                cancel(false);
            }
        }

        try {
            if (frameGrabber != null) {
                frameGrabber.stop();
                frameGrabber.release();
            }
        } catch (Exception ex) {
            logger.log(Level.SEVERE, "Could not release FrameGrabber.", ex);
        } finally {
            frameGrabber = null;
            grabberConverter = null;
        }

        try {
            if (frameRecorder != null) {
                frameRecorder.stop();
                frameRecorder.release();
            }
        } catch (Exception ex) {
            logger.log(Level.SEVERE, "Could not release FrameRecorder.", ex);
        } finally {
            frameRecorder = null;
            recorderConverter = null;
        }

        if (trackingSettings.useOpenCL) {
            grabbedImageCL.release();
            undistortedCameraImageCL.release();
            contextCL.releaseCLGLImage(distortedProjectorImageCL);
            reflectanceImageCL.release();
            cameraMapxCL.release();
            cameraMapyCL.release();
            projectorMapxCL.release();
            projectorMapyCL.release();
            grabbedImageCL = undistortedCameraImageCL = distortedProjectorImageCL = null;
            reflectanceImageCL = null;
            cameraMapxCL = cameraMapyCL = projectorMapxCL = projectorMapyCL = null;

            contextCL.release();
            contextCL = null;
        }

        roiPts = null;
        transformer = null;
        parameters = lastParameters = tempParameters = null;
        aligner = null;
        reflectanceInitializer = null;
        handMouse = null;
        realityAugmentor = null;

        grabbedImage = undistortedCameraImage = distortedProjectorImage = null;
        projectorInitFloatImages = projectorInitImages = null;
        cameraInitImages = cameraInitFloatImages = monitorImages = null;
        reflectanceImage = null;

        projectorBufferRing.release();
        projectorBufferRing = null;

        // force release of native memory
        System.gc();
        Pointer.deallocateReferences();

        return null;
    }
351172
def onWith(self, evnt, func):
        '''
        
        '''
        self.on(evnt, func)
        # Allow exceptions to propagate during the context manager
        # but ensure we cleanup our temporary callback
        try:
            yield self
        finally:
            self.off(evnt, func)
871790
function() {
    if (this.handler) {
      this.handler();
      if (mindmaps.DEBUG) {
        console.log("handler called for", this.id);
      }
    } else {
      if (mindmaps.DEBUG) {
        console.log("no handler found for", this.id);
      }
    }
  }
1198961
function() {
		gui.TrackerPlugin.prototype.onconstruct.call(this);
		this.context = self; // TODO: deprecate this whole thing...
		this._watches = [];
		this._matches = [];
		this._needing = [];
	}
791406
def monitor(self, name, ip, port, quorum):
        """"""
        fut = self.execute(b'MONITOR', name, ip, port, quorum)
        return wait_ok(fut)
1338864
public static <ReqT, RespT> RespT blockingUnaryCall(ClientCall<ReqT, RespT> call, ReqT req) {
    try {
      return getUnchecked(futureUnaryCall(call, req));
    } catch (RuntimeException e) {
      throw cancelThrow(call, e);
    } catch (Error e) {
      throw cancelThrow(call, e);
    }
  }
932070
def watch(watch_value, &block)
      new_thread = Thread.new do
        prev_value = (self.read == GPIO_HIGH ? GPIO_LOW : GPIO_HIGH)

        loop do
          current_value = self.read
          flip = (prev_value != current_value)

          if current_value == watch_value && flip
            self.instance_exec &block
          end

          prev_value = current_value

          sleep WATCH_POLLING_SEC
        end
      end

      new_thread.abort_on_exception = true
      new_thread
    end
1078561
Set<ProbeListener> removeListenersForMonitor(Object monitor) {
        Set<ProbeListener> listeners = null;

        listenersLock.writeLock().lock();
        try {
            listeners = listenersForMonitor.remove(monitor);
            if (listeners == null) {
                listeners = Collections.emptySet();
            } else {
                allRegisteredListeners.removeAll(listeners);
            }
        } finally {
            listenersLock.writeLock().unlock();
        }

        return listeners;
    }
622743
function(count, opts, cb) {
  this.count = count;
  this.cb = cb;
  var self = this;
  if (opts.timeout) {
    this.timerId = setTimeout(function() {
      self.cb(true);
    }, opts.timeout);
  }
}
406789
def monitor(interests=:rw)
      @monitor ||= begin
        raise @error if @error
        monitor = @ioloop.add_io_wait(@io, interests) {callback_on_waiting}
        ObjectSpace.define_finalizer(self, self.class.finalizer(monitor))
        monitor
      end
    end
526110
function _check(){
            if(_checkReady(target)){
                clearInterval(timeHandle);
                timeHandle = null;
                _call();

                isReady = true;
            }               
        }
428750
@AroundInvoke
	public Object monitor(InvocationContext context) throws Exception {
		if (isMonitored(context)) {
			String simonName = getSimonName(context);
			try (Split ignored = SimonManager.getStopwatch(simonName).start()) {
				return context.proceed();
			}
		} else {
			return context.proceed();
		}
	}
577968
function (len) {
    _.isNumber(len) || (len = 1)
    
    while (len--) {
      readline.moveCursor(this.rl.output, -cliWidth(), 0)
      readline.clearLine(this.rl.output, 0)
      if (len) {
        readline.moveCursor(this.rl.output, 0, -1)
      }
    }
    return this
  }
1082442
function monitor(server) {
  // cannot receive data anymore we just send it
  this.removeAllListeners('data');

  var listener = this.request.bind(this);

  // keep track of the monitor listeners
  // for clean up
  server._monitor[this.id] = listener;

  // flag on the client for client list flags
  this._client.monitor = true;

  server.on('monitor', listener);
}