Oracle Coherence for C++ API
Release 3.6.1.0

E18813-01

PriorityTask Class Reference

#include <coherence/net/PriorityTask.hpp>

Inherits Object.

Inherited by AbstractPriorityTask [virtual].

List of all members.


Detailed Description

The PriorityTask interface allows to control the ordering in which a service schedules tasks for execution using a thread pool and limit their execution times to a specified duration.

Instances of PriorityTask typically also implement either PriorityTask or Runnable interface.

Depending on the value returned by the getSchedulingPriority() method, the scheduling order will be one of the following:

A best effort will be made to limit the task execution time according to the value returned by the getExecutionTimeoutMillis() method. However, it should be noted that:

In addition to allowing control of the task execution (as scheduled and measured on the server side), the PriorityTask interface could also be used to control the request time from the calling thread perspective (measured on the client). A best effort will be made to limit the request time (the time period that the calling thread is blocked waiting for a response from the corresponding service) to the value returned by the getRequestTimeoutMillis() method.

It should be noted that the request timeout value (RT) could be grater than, equal to or less than the task execution timeout value (ET). The value of RT which is less than ET indicates that even though the task execution is allowed to take longer period of time, the client thread will not wait for a result of the execution and will be able to handle a timeout exception if it arises. Since the time spent by the task waiting in the service backlog queue does not count toward the task execution time, a value of RT that is equal or slightly greater than ET still leaves a possibility that the client thread will throw a TimeoutException before the task completes its execution normally on a server.

Author:
djl 2008.05.15

Public Types

typedef spec::Handle  Handle
  PriorityTask Handle definition.
typedef spec::View  View
  PriorityTask View definition.
typedef spec::Holder  Holder
  PriorityTask Holder definition.

Public Member Functions

virtual int32_t  getSchedulingPriority () const =0
  Obtain this task's scheduling priority.
virtual int64_t  getExecutionTimeoutMillis () const =0
  Obtain the maximum amount of time this task is allowed to run before the corresponding service will attempt to stop it.
virtual int64_t  getRequestTimeoutMillis () const =0
  Obtain the maximum amount of time a calling thread is willing to wait for a result of the request execution.
virtual void  runCanceled (bool fAbandoned)=0
  This method will be called if and only if all attempts to interrupt this task were unsuccesful in stopping the execution or if the execution was canceled before it had a chance to run at all.

Static Public Attributes

static const int32_t  SCHEDULE_STANDARD
  Scheduling value indicating that this task is to be queued and executed in a natural (based on the request arrival time) order.
static const int32_t  SCHEDULE_FIRST
  Scheduling value indicating that this task is to be queued in front of any equal or lower scheduling priority tasks and executed as soon as any of the worker threads become available.
static const int32_t  SCHEDULE_IMMEDIATE
  Scheduling value indicating that this task is to be immediately executed by any idle worker thread; if all of them are active, a new thread will be created to execute this task.
static const int64_t  TIMEOUT_DEFAULT
  A special timeout value to indicate that the corresponding service's default timeout value should be used.
static const int64_t  TIMEOUT_NONE
  A special timeout value to indicate that this task or request can run indefinitely.

Member Function Documentation

virtual int32_t getSchedulingPriority (  )  const [pure virtual]

Obtain this task's scheduling priority.

Valid values are one of the SCHEDULE_* constants.

Returns:
this task's scheduling priority

Implemented in AbstractPriorityTask.

virtual int64_t getExecutionTimeoutMillis (  )  const [pure virtual]

Obtain the maximum amount of time this task is allowed to run before the corresponding service will attempt to stop it.

The value of TIMEOUT_DEFAULT indicates a default timeout value configured for the corresponding service; the value of TIMEOUT_NONE indicates that this task can execute indefinitely.

If, by the time the specified amount of time passed, the task has not finished, the service will attempt to stop the execution by using the Thread::interrupt() method. In the case that interrupting the thread does not result in the task's termination, the runCanceled method will be called.

Returns:
the execution timeout value in millisecods or one of the special TIMEOUT_* values

Implemented in AbstractPriorityTask.

virtual int64_t getRequestTimeoutMillis (  )  const [pure virtual]

Obtain the maximum amount of time a calling thread is willing to wait for a result of the request execution.

The request time is measured on the client side as the time elapsed from the moment a request is sent for execution to the corresponding server node(s) and includes:

The value of TIMEOUT_DEFAULT indicates a default timeout value configured for the corresponding service; the value of TIMEOUT_NONE TIMEOUT_NONE indicates that the client thread is willing to wait indefinitely until the task execution completes or is canceled by the service due to a task execution timeout specified by the getExecutionTimeoutMillis() value.

If the specified amount of time elapsed and the client has not received any response from the server, an RequestTimeoutException will be thrown to the caller.

Returns:
the request timeout value in milliseconds or one of the special TIMEOUT_* values

Implemented in AbstractPriorityTask.

virtual void runCanceled ( bool  fAbandoned  )  [pure virtual]

This method will be called if and only if all attempts to interrupt this task were unsuccesful in stopping the execution or if the execution was canceled before it had a chance to run at all.

Since this method is usually called on a service thread, implementors must exercise extreme caution since any delay introduced by the implementation will cause a delay of the corresponding service.

Parameters:
fAbandoned  true if the task has timed-out, but all attempts to interrupt it were unsuccesful in stopping the execution; otherwise the task was never started

Implemented in AbstractPriorityTask.


The documentation for this class was generated from the following file:
Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.