/*
(non-Javadoc)

@see org.jgrapes.core.EventPipeline#submit(java.lang.Runnable)
322914
@Override
    public void submit(String name, Runnable action) {
        ActionEvent<Void> event = ActionEvent.create(name, action);
        sink.add(event, Channel.BROADCAST);
    }
141552
protected synchronized void submit() {
    try {
      if (theJobConf.getBoolean("create.empty.dir.if.nonexist", false)) {
        FileSystem fs = FileSystem.get(theJobConf);
        Path inputPaths[] = FileInputFormat.getInputPaths(theJobConf);
        for (int i = 0; i < inputPaths.length; i++) {
          if (!fs.exists(inputPaths[i])) {
            try {
              fs.mkdirs(inputPaths[i]);
            } catch (IOException e) {

            }
          }
        }
      }
      RunningJob running = jc.submitJob(theJobConf);
      this.mapredJobID = running.getID();
      this.state = Job.RUNNING;
    } catch (IOException ioe) {
      this.state = Job.FAILED;
      this.message = StringUtils.stringifyException(ioe);
    }
  }
658177
public Future<?> submitAfter(Waiter waiter, Runnable runnable, long timeout, TimeUnit unit)
    {
        AfterTask<?> task = new AfterTask<>(waiter, runnable, timeout, unit);
        log(logLevel, "submit after task %s", task);
        return submit(task);
    }
136076
public T input(final BooleanRunnable runnable) {
        if (view != null && view instanceof EditText) {
            EditText editText = (EditText) view;
            if ((editText.getInputType() & TYPE_TEXT_FLAG_MULTI_LINE) == 0)
                editText.setOnKeyListener(new View.OnKeyListener() {

                    public boolean onKey(View v, int keyCode, KeyEvent event) {
                        if (keyCode != KEYCODE_ENTER)
                            return false;
                        if (event == null)
                            return false;
                        if (event.getAction() != ACTION_DOWN)
                            return false;

                        return runnable.run();
                    }
                });

            editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                    if (actionId == IME_ACTION_DONE)
                        return runnable.run();
                    else
                        return false;
                }
            });
        }
        return self();
    }
709420
@Override
  @SuppressWarnings("checkstyle:illegalcatch")
  public void onNext(final T value) {
    beforeOnNext();
    try {
      executor.submit(new Runnable() {

        @Override
        public void run() {
          try {
            handler.onNext(value);
          } catch (final Throwable t) {
            if (errorHandler != null) {
              errorHandler.onNext(t);
            } else {
              LOG.log(Level.SEVERE, name + " Exception from event handler", t);
              throw t;
            }
          } finally {
            afterOnNext();
          }
        }

      });
    } catch (final Exception e) {
      LOG.log(Level.SEVERE, "Encountered error when submitting to executor in ThreadPoolStage.");
      afterOnNext();
      throw e;
    }

  }
1255259
public Future<V> submit(Callable<V> task) {
        if (task == null) throw new NullPointerException();
        NotifyingFuture<V> f = executor.submit(task);
        f.setListener(listener);
        return f;
    }
1040101
@Override
    public void execute(Runnable task) {
        // count a new task in process
        tasksInProcess.incrementAndGet();
        try {
            super.execute(task);
        } catch (RuntimeException e) { // specifically handle RejectedExecutionException
            tasksInProcess.decrementAndGet();
            throw e;
        } catch (Error e) {
            tasksInProcess.decrementAndGet();
            throw e;
        }
    }
1052558
public void submit(Map<String, String> additionalMetadata) throws IOException {

    if (this.submitted) {
      throw new IOException("MultiTimingEvent has already been submitted.");
    }
    this.submitted = true;

    endStage();

    Map<String, String> finalMetadata = Maps.newHashMap();
    finalMetadata.putAll(additionalMetadata);
    finalMetadata.put(EventSubmitter.EVENT_TYPE, MULTI_TIMING_EVENT);
    for (Stage timing : this.timings) {
      finalMetadata.put(timing.getName(), Long.toString(timing.getDuration()));
    }

    this.submitter.submit(this.name, finalMetadata);
  }
781244
@Override
	protected void submitRedoPut(final K key, final V value) {
		if (!useRedo) {
			return;
		}
		createRedoThread();
		final ByteBuffer buf = bufstack.pop();
		buf.put((byte) 0x0A); // PUT HEADER
		key.serialize(buf);
		value.serialize(buf);
		buf.put((byte) 0x0A); // PUT FOOTER
		buf.flip();
		if (useRedoThread) {
			try {
				redoQueue.put(buf);
			} catch (InterruptedException e) {
				log.error("InterruptedException in submitRedoPut(key, value)", e);
			}
		} else {
			redoStore.write(buf);
			bufstack.push(buf);
		}
	}
337897
protected void submit() {

        if (m_userinfoNoEditGroup.getRows().size() != m_addInfoReadOnly.size()) {
            List<String> currentKeys = getKeyListFromGroup(m_userinfoNoEditGroup);
            for (String key : m_addInfoReadOnly.keySet()) {
                if (!currentKeys.contains(key)) {
                    saveAddInfo(key, null);
                }
            }
        }

        for (I_CmsEditableGroupRow row : m_userinfoGroup.getRows()) {
            String key = ((TextField)(((HorizontalLayout)row.getComponent()).getComponent(0))).getValue();
            String value = ((TextField)(((HorizontalLayout)row.getComponent()).getComponent(1))).getValue();
            saveAddInfo(key, value);
            m_addInfoEditable.remove(key);
        }

        //Remaining items in list seem to be deleted by the user..
        for (String key : m_addInfoEditable.keySet()) {
            saveAddInfo(key, null);
        }
        try {
            m_cms.writeUser(m_user);
        } catch (CmsException e) {
            LOG.error("Unable to write user.", e);
        }
    }
296789
public static void SubmitDelayed( long millis, Runnable task ) {
        Actors.delayedCalls.schedule( new TimerTask() {
            @Override
            public void run() {
                task.run();
            }
        },millis);
    }
352919
@Override
    public <T> Future<T> submit(Callable<T> task) {
        try {
            if (this.concurrentExecutor instanceof ExecutorService) {
                return ((ExecutorService) this.concurrentExecutor).submit(task);
            } else {
                FutureTask<T> future = new FutureTask<T>(task);
                this.concurrentExecutor.execute(future);
                return future;
            }
        } catch (RejectedExecutionException ex) {
            throw new TaskRejectedException("Executor [" + this.concurrentExecutor + "] did not accept task: " + task,
                    ex);
        }
    }
1328214
public <T> Future<T> submit(Callable<T> callable) {
		checkThreadQueue();
		return threadPool.submit(callable);
	}
174687
@Override
    public synchronized void submit(long offset) {
        if (submittedOffset == -1L && offset >= 0) {
            committedOffsets[idx(offset)] = safeOffset = submittedOffset = offset;
        }
        if (firstOffset == -1L) {
            firstOffset = offset;
        }
        if ((offset - safeOffset) >= committedOffsets.length) {
            offerOffset = offset;
            try {
                wait(m_gapFullWait);
            } catch (InterruptedException e) {
                LOGGER.rateLimitedLog(LOG_SUPPRESSION_INTERVAL_SECONDS,
                        Level.WARN, e, "CommitTracker wait was interrupted for group " + consumerGroup + " topic " + topic + " partition " + partition);
            }
        }
        if (offset > submittedOffset) {
            submittedOffset = offset;
        }
    }
1329721
private <T> void submitQuery(QueryRequest request, CompletableFuture<T> future) {
    submit(new QueryAttempt<>(sequencer.nextRequest(), request, future));
  }
797217
def submit(self):
        """"""
        if self._dirty:
            self.save()

        self._connection.run(['submit', '-c', str(self._change)], marshal_output=False)
941678
void submit() {

        //        if (!m_dateField.isValid()) {
        //            return;
        //        }
        long current = System.currentTimeMillis();
        Date dateValue = m_dateField.getDate();
        long publishTime = dateValue.getTime();
        if (current > publishTime) {
            m_context.error(
                new CmsException(Messages.get().container(Messages.ERR_PUBLISH_SCHEDULED_DATE_IN_PAST_1, dateValue)));
        } else {
            try {
                // make copies from the admin cmsobject and the user cmsobject
                // get the admin cms object
                CmsWorkplaceAction action = CmsWorkplaceAction.getInstance();
                CmsObject cmsAdmin = action.getCmsAdminObject();
                // get the user cms object
                CmsObject cms = OpenCms.initCmsObject(m_context.getCms());

                // set the current user site to the admin cms object
                cmsAdmin.getRequestContext().setSiteRoot(cms.getRequestContext().getSiteRoot());
                CmsProject tmpProject = createTempProject(cmsAdmin, m_context.getResources(), dateValue);
                // set project as current project
                cmsAdmin.getRequestContext().setCurrentProject(tmpProject);
                cms.getRequestContext().setCurrentProject(tmpProject);

                Set<CmsUUID> changeIds = new HashSet<CmsUUID>();
                for (CmsResource resource : m_context.getResources()) {
                    addToTempProject(cmsAdmin, cms, resource, tmpProject);
                    if (resource.isFolder() && m_includeSubResources.getValue().booleanValue()) {
                        List<CmsResource> subResources = cms.readResources(
                            resource,
                            CmsResourceFilter.ONLY_VISIBLE.addExcludeState(CmsResourceState.STATE_UNCHANGED),
                            true);
                        for (CmsResource sub : subResources) {
                            // check publish permissions on sub resource
                            if (cms.hasPermissions(
                                sub,
                                CmsPermissionSet.ACCESS_DIRECT_PUBLISH,
                                false,
                                CmsResourceFilter.ALL)) {
                                addToTempProject(cmsAdmin, cms, sub, tmpProject);
                            }
                        }
                    }

                    changeIds.add(resource.getStructureId());
                }
                // create a new scheduled job
                CmsScheduledJobInfo job = new CmsScheduledJobInfo();
                // the job name
                String jobName = tmpProject.getName();
                jobName = jobName.replace("&#47;", "/");
                // set the job parameters
                job.setJobName(jobName);
                job.setClassName("org.opencms.scheduler.jobs.CmsPublishScheduledJob");
                // create the cron expression
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(dateValue);
                String cronExpr = ""
                    + calendar.get(Calendar.SECOND)
                    + " "
                    + calendar.get(Calendar.MINUTE)
                    + " "
                    + calendar.get(Calendar.HOUR_OF_DAY)
                    + " "
                    + calendar.get(Calendar.DAY_OF_MONTH)
                    + " "
                    + (calendar.get(Calendar.MONTH) + 1)
                    + " "
                    + "?"
                    + " "
                    + calendar.get(Calendar.YEAR);
                // set the cron expression
                job.setCronExpression(cronExpr);
                // set the job active
                job.setActive(true);
                // create the context info
                CmsContextInfo contextInfo = new CmsContextInfo();
                contextInfo.setProjectName(tmpProject.getName());
                contextInfo.setUserName(cmsAdmin.getRequestContext().getCurrentUser().getName());
                // create the job schedule parameter
                SortedMap<String, String> params = new TreeMap<String, String>();
                // the user to send mail to
                String userName = m_context.getCms().getRequestContext().getCurrentUser().getName();
                params.put(CmsPublishScheduledJob.PARAM_USER, userName);
                // the job name
                params.put(CmsPublishScheduledJob.PARAM_JOBNAME, jobName);
                // the link check
                params.put(CmsPublishScheduledJob.PARAM_LINKCHECK, "true");
                // add the job schedule parameter
                job.setParameters(params);
                // add the context info to the scheduled job
                job.setContextInfo(contextInfo);
                // add the job to the scheduled job list
                OpenCms.getScheduleManager().scheduleJob(cmsAdmin, job);
                // update the XML configuration
                OpenCms.writeConfiguration(CmsSchedulerConfiguration.class);
                m_context.finish(changeIds);
            } catch (CmsException ex) {
                LOG.error("Error performing publish scheduled dialog operation.", ex);
                m_context.error(ex);
            }
        }

    }