home *** CD-ROM | disk | FTP | other *** search
- /***********************************************************************
- **+
- ** Module Name: workflow.h
- **
- ** Description: Workflow specific defines
- **
- ** Include Modules Referenced: None.
- **
- ** Written by: John Tal
- **
- **
- ** Modification history:
- **
- ** Date Engineer Mod # Modification Description
- **
- ** 07-Jul-1991 Tal v 1.0-001 Initial release
- **-
- ***********************************************************************/
-
- #ifdef WFL_H
- #else
- #define WFL_H
-
- #define WFL_KEY_LEN 16 /* standard key length */
- #define WFL_MAX_TRN_STATES 10 /* limit of transition states per profile */
-
- #define WFL_NO_JOB -1 /* no jobs for a process */
-
-
- /*
- ** A workflow management system is a way to coordinate several processes
- ** which are all processing the same set of data. The environment
- ** in which the concept was developed at I2MS was for distributed Unix
- ** processing. Concept was defined by Mike Peregoy and implemented by
- ** the I2MS Blue Shield Imaging team lead by John Tal (Spring 1991).
- **
- ** Basically, a workflow management system (WMS) is a way to 'send' jobs
- ** around a network through various states or queues. A particular
- ** process is looking for jobs with a particular state. Jobs it finds
- ** with a matching state are taken and locked for processing. When that
- ** process is finished processing a job, it resets the state to another
- ** value. This value is likely a selection value for another process.
- **
- ** Network
- **
- ** Process 1 Loads jobs into database
- ** Sets Jobs to state 200
- **
- ** Process 2 Looking for Jobs with state 200
- ** Sets completed Jobs to state 300
- **
- ** Process 3 Looking for Jobs with state 300
- ** Sets completed Jobs to state 400
- **
- ** Process 4 Looking for Jobs with state 300
- ** Deletes jobs from database
- **
- **
- **
- ** A major advantage to a WMS is the ability for the system manager to
- ** 'customize' the operation of the system. (Process 3 could execute
- ** before Process 2.)
- **
- ** A review of WMS for the right-side of the brain.....
- **
- ** All of these processes are plugged into this network
- ** and grab any jobs they can. After processing, they
- ** set the job state so that another process can have some
- ** fun.
- **
- ** The program below is an example of how to use the C algorithms in
- ** constructing a WMS based on an in-memory database.
- **
- ** A WMS would typically be created in a library layer above the
- ** disk-based data-base.
- **
- ** FURTHER DEVELOPMENT
- **
- ** An evolution to the EMS (especially meaningful in a multi-tasking
- ** environment) would be to have each process block until a job is
- ** available for processing. This would eliminate the constant
- ** polling to the database.
- **
- ** To implement a priority-based scheme, you could add a priority to
- ** each job and change the link-list off each state node in the
- ** binary tree to a heap. The only limitation is that because most
- ** heaps are implemented in arrays, you would have to allocate for a
- ** maximum size if only one job existed at a given state.
- **
- */
-
-
-
- /*
- ** The following item is at each node of the workflow binary tree
- **
- ** The workflow binary tree has one node for each state. All jobs
- ** for the same state are connected in a link-list off of the binary
- ** tree node for that state.
- */
-
- struct WORK_TREE_S
- {
- SHORT sState; /* the state */
- LLIST_P pstList; /* ptr to the list of jobs at that state */
- };
-
- typedef struct WORK_TREE_S WORK_TREE_T;
- typedef WORK_TREE_T * WORK_TNODE_P;
-
-
- /*
- ** The workflow data (WORK_ITEM_S) is stored in a linked-list hung off
- ** of a binary tree.
- **
- ** The WORK_ITEM is data about each job.
- */
-
- struct WORK_ITEM_S
- {
- SHORT sState; /* the state, or queue job is currently at */
- CHAR szId[WFL_KEY_LEN + 1]; /* unique identifier for job */
- CHAR szKey[WFL_KEY_LEN + 1]; /* current or last owners Id */
- BOOL fLocked; /* is currently in use */
- PVOID pvData; /* common data type all processes/owners are using */
- };
-
- typedef struct WORK_ITEM_S WORK_ITEM_T;
- typedef WORK_ITEM_T * WORK_ITEM_P;
- typedef WORK_ITEM_T ** WORK_ITEM_PP;
-
-
- /*
- ** This is the workflow profile data
- **
- ** It is contained in a linked list which is belongs to a process.
- **
- ** This is a profile to describe how each 'process' is to access the data.
- ** A process initializes for this data once and then does queries against
- ** the master set of WORK_ITEM data to get a job for processing.
- **
- ** The profile data contains the selection, activation, and transition
- ** state values. A process may have multiple WORK_FLOW entries as
- ** part of its profile.
- **
- ** The profile data would normally be stored in a file on disk.
- */
-
-
- /*
- ** The following are the array [] offsets for each type of state in the
- ** WORK_FLOW . sTrnState[]
- */
-
- #define WFL_SEL_STATE 0
- #define WFL_ACT_STATE 1
- #define WFL_TRN_STATE 2
-
- /*
- ** each process would typically have it's own meaning for the
- ** transition values. Here are some generic ones
- **/
-
- #define WFL_TRN_OK 0
- #define WFL_TRN_ERR_1 1
- #define WFL_TRN_ERR_2 2
-
- struct WORK_FLOW_S
- {
- CHAR szKey[WFL_KEY_LEN + 1]; /* Key = ID of process */
- SHORT sTrnState[10]; /* States themselves */
- SHORT sTrnStates; /* How many states are there */
- };
-
- typedef struct WORK_FLOW_S WORK_FLOW_T;
- typedef WORK_FLOW_T * WORK_FLOW_P;
- typedef WORK_FLOW_T ** WORK_FLOW_PP;
-
-
-
- #ifdef C_ANSI
-
- SHORT APIENTRY
- WflProAdd(LLIST_PP, WORK_FLOW_P);
-
- SHORT APIENTRY
- WflJobAdd(TNODE_PP,WORK_ITEM_P);
-
- SHORT APIENTRY
- WflJobSelect(TNODE_P,
- LLIST_P,
- WORK_FLOW_PP,
- WORK_ITEM_PP,
- PVOID *);
-
- SHORT APIENTRY
- WflJobTrans(TNODE_PP,
- WORK_ITEM_P,
- WORK_FLOW_P,
- SHORT,
- BOOL);
-
- SHORT CompareState(PVOID,PVOID);
-
- SHORT CompareNodeState(PVOID,PVOID);
-
- #else
-
- SHORT APIENTRY WflProAdd();
- SHORT APIENTRY WflJobAdd();
- SHORT APIENTRY WflJobSelect();
- SHORT APIENTRY WflJobTrans();
- SHORT CompareState();
- SHORT CompareNodeState();
-
- #endif
-
-
-
- #endif