Finish synchronizing a source that was updated via #start_synchronize.
 This method returns self if the source is already synchronized. Otherwise
 it parses the AST and returns a new synchronized Source.

 @return [Source]
6069
def finish_synchronize
      return self if synchronized?
      synced = Source.new(@code, filename)
      if synced.parsed?
        synced.version = version
        return synced
      end
      synced = Source.new(@repaired, filename)
      synced.error_ranges.concat (error_ranges + last_updater.changes.map(&:range))
      synced.code = @code
      synced.synchronized = true
      synced.version = version
      synced
    end
1241203
def sync(self):
        
        if self._sync:
            return  # opened in sync mode, so skip the manual sync
        self._sync = True
        for ekey in self._buffer:
            filename = self._key_to_filename(ekey)
            self._write_to_file(filename, self._buffer[ekey])
        self._buffer.clear()
        self._sync = False
545137
def sync_sources(self, force=False):
        """"""
        from ambry.orm.file import File

        self.dstate = self.STATES.BUILDING

        synced = 0

        for fc in [File.BSFILE.SOURCES]:
            bsf = self.build_source_files.file(fc)
            if bsf.fs_is_newer or force:
                self.log('Syncing {}'.format(bsf.file_name))
                bsf.fs_to_objects()
                synced += 1

        return synced
1017892
def sync_events(sync_m, *args)
      if args[0].is_a?(PredictionIO::AsyncResponse)
        response = args[0].get
      else
        response = send(sync_m, *args).get
      end
      return JSON.parse(response.body) if response.is_a?(Net::HTTPOK)
      begin
        msg = response.body
      rescue
        raise response
      end
      if response.is_a?(Net::HTTPBadRequest)
        fail BadRequestError, msg
      elsif response.is_a?(Net::HTTPNotFound)
        fail NotFoundError, msg
      elsif response.is_a?(Net::HTTPServerError)
        fail ServerError, msg
      else
        fail msg
      end
    end
1289329
def on_threadpool?
      tp = nil

      @mutex.synchronize do
        return false unless @threadpool # you can't dup nil
        tp = @threadpool.dup
      end

      tp.respond_to?(:include?) and tp.include?(Thread.current)
    end
968946
def process_push
      factory = "::#{object_type}".constantize
      local_object = factory.find(object_local_id)
      syncer = factory.synchronizer
      syncer.push_object(local_object)
      
      self.state = 'done'
      self.save
    end
764477
def import(source_adapter)
      Adapters::Sync::Synchronizer.new(self, source_adapter, raise: true).call
    end
923765
def wait_until_synced(attr)
      attr = attr.to_sym
      waited = 0
      while true
        return if attribute_synced?(attr)
        waited += 1

        if waited % 100 == 0
          bot.loggers.warn "A synced attribute ('%s' for %s) has not been available for %d seconds, still waiting" % [attr, self.inspect, waited / 10]
          bot.loggers.warn caller.map {|s| "  #{s}"}

          if waited / 10 >= 30
            bot.loggers.warn "  Giving up..."
            raise Exceptions::SyncedAttributeNotAvailable, "'%s' for %s" % [attr, self.inspect]
          end
        end
        sleep 0.1
      end
    end
1182456
def merge source
      result = nil
      mutex.synchronize do
        result = workspace.merge(source)
        @synchronized = !result if synchronized?
      end
      result
    end
274918
def sync_attr_sync(attribute, &block)
      mutex_var_name = "@sync_attr_#{attribute}".to_sym
      instance_variable_set(mutex_var_name, Mutex.new) unless instance_variable_defined?(mutex_var_name)
      instance_variable_get(mutex_var_name).synchronize(&block)
    end
961618
def pop
      @monitor.synchronize do
        if @events.empty?
          raise ThreadError, "queue empty" if @shutdown
          @resource.wait
        else
          delay = @events.first.at - Time.now
          @resource.wait(delay) if delay > 0
        end

        @events.shift
      end
    end
1187215
def _synced(method, self, args, kwargs):
    """"""
    with self._lock:
        return method(*args, **kwargs)
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);
                });
    }
1040983
def transaction(force_sync = false, &block)
      # Ruby 1.9.3 does not support @mutex.owned?
      if @mutex.respond_to?(:owned?)
        force_sync = false if @mutex.locked? && @mutex.owned?
      else
        # If we allowed this in Ruby 1.9.3, it might possibly cause recursive
        # locking within the same thread.
        force_sync = false
      end
      if !force_sync && (@in_transaction || options[:without_mutex])
        block.call self
      else
        @mutex.synchronize do
          @in_transaction = true
          result = block.call
          @in_transaction = false
          result
        end
      end
    end
346438
def sync_getch
      return self.getch unless sync_enabled?

      c = -1
      while c == -1 && !shutdown?
        c = self.getch
        run_sync!
      end

      c
    end
365927
def add_source(source)
      @semaphore.synchronize do
        @sources << source
      end

      if @registry.frozen?
        # already frozen, must reload everything
        self.reload!
      else
        @semaphore.synchronize do
          Fwissr.merge_conf!(@registry, source.get_conf)
        end
      end

      self.ensure_refresh_thread
    end
773163
def close_thread_queues
      still_active = false
      @mutex.synchronize do
        @thread_name_to_queue.each_value do |queue|
          if queue.active?
            queue.close
            still_active = true
          end
        end
      end
      return still_active
    end