8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-30 19:23:03 +01:00
firebird-mirror/src/jrd/event.h

184 lines
5.3 KiB
C
Raw Normal View History

2001-05-23 15:26:42 +02:00
/*
* PROGRAM: JRD Access Method
* MODULE: event.h
* DESCRIPTION: Event manager definitions
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*
* 23-Feb-2002 Dmitry Yemanov - Events wildcarding
*
*
* 2002-02-23 Sean Leyne - Code Cleanup, removed old Win3.1 port (Windows_Only)
*
2001-05-23 15:26:42 +02:00
*/
#ifndef JRD_EVENT_H
#define JRD_EVENT_H
2001-05-23 15:26:42 +02:00
#include "../jrd/isc.h"
#include "../jrd/file_params.h"
#define PTR SLONG
#define BASE ((UCHAR *) EVENT_header)
#define REL_PTR(item) ((UCHAR *) item - BASE)
#define ABS_PTR(item) (BASE + item)
#define ACQUIRE acquire()
#define RELEASE release()
#define QUE_INIT(que) {que.srq_forward = que.srq_backward = REL_PTR (&que);}
#define QUE_EMPTY(que) (que.srq_forward == REL_PTR (&que))
#define QUE_NEXT(que) ABS_PTR (que.srq_forward)
#define QUE_PREV(que) ABS_PTR (que.srq_backward)
2001-05-23 15:26:42 +02:00
#define QUE_LOOP(header,que) for (que = (SRQ*) QUE_NEXT (header);\
que != &header; que = (SRQ*) QUE_NEXT ((*que)))
2004-04-29 13:16:31 +02:00
const int SIZE_SHIFT = 2;
const int FAST_ALLOC = 16;
2001-05-23 15:26:42 +02:00
/* Self-relative que block. Offsets are from the block itself. */
typedef struct srq {
PTR srq_forward; /* Forward offset */
PTR srq_backward; /* Backward offset */
} SRQ;
/* Global section header */
2004-04-29 13:16:31 +02:00
const int EVH_HASH_SIZE = 7;
2001-05-23 15:26:42 +02:00
typedef struct evh {
SLONG evh_length; /* Current length of global section */
UCHAR evh_version; /* Version number of global section */
SRQ evh_events; /* Known processes */
SRQ evh_processes; /* Known processes */
PTR evh_free; /* Free blocks */
PTR evh_current_process; /* Current process, if any */
MTX_T evh_mutex[1]; /* Mutex controlling access */
SLONG evh_request_id; /* Next request id */
PTR evh_hash_table[EVH_HASH_SIZE];
} *EVH;
/* Common block header */
2004-04-29 13:16:31 +02:00
const int type_hdr = 1; // Event header
const int type_frb = 2; // Free block
const int type_prb = 3; // Process block
const int type_rint = 4; // Request interest block
const int type_reqb = 5; // Request block previously req_type also used in blk.h
const int type_evnt = 6; // Event
const int type_ses = 7; // Session
const int type_max = 8;
2001-05-23 15:26:42 +02:00
struct event_hdr // CVC: previous clash with ods.h's hdr
2001-05-23 15:26:42 +02:00
{
SLONG hdr_length; /* Length of block */
UCHAR hdr_type; /* Type of block */
};
2001-05-23 15:26:42 +02:00
/* Free blocks */
struct frb
2001-05-23 15:26:42 +02:00
{
event_hdr frb_header;
2001-05-23 15:26:42 +02:00
SLONG frb_next; /* Next block */
};
typedef frb *FRB;
2001-05-23 15:26:42 +02:00
/* Process blocks */
struct prb
2001-05-23 15:26:42 +02:00
{
event_hdr prb_header;
2001-05-23 15:26:42 +02:00
SRQ prb_processes; /* Process que owned by header */
SRQ prb_sessions; /* Sessions within process */
SLONG prb_process_id; /* Process id */
SLONG prb_process_uid[2]; /* Process UID (apollo) */
event_t prb_event[1]; /* Event on which to wait */
2001-05-23 15:26:42 +02:00
USHORT prb_flags;
};
typedef prb *PRB;
2001-05-23 15:26:42 +02:00
2004-04-29 13:16:31 +02:00
const int PRB_wakeup = 1; /* Schedule a wakeup for process */
const int PRB_pending = 2; /* Wakeup has been requested, and is dangling */
const int PRB_remap = 4; /* need to remap shared memory */
const int PRB_remap_over= 8; /* remap is over */
const int PRB_exiting = 16; /* Process is exiting */
2001-05-23 15:26:42 +02:00
/* Session block */
struct ses {
event_hdr ses_header;
2001-05-23 15:26:42 +02:00
SRQ ses_sessions; /* Sessions within process */
SRQ ses_requests; /* Outstanding requests */
PTR ses_interests; /* Historical interests */
PTR ses_process; /* Parent process */
#ifdef MULTI_THREAD
USHORT ses_flags;
#endif
};
typedef ses *SES;
2001-05-23 15:26:42 +02:00
#define SES_delivering 1 /* Watcher thread is delivering an event */
/* Event block */
struct evnt {
event_hdr evnt_header;
2001-05-23 15:26:42 +02:00
SRQ evnt_events; /* System event que (owned by header) */
SRQ evnt_interests; /* Que of request interests in event */
PTR evnt_hash_collision; /* Hash table collision pointer */
PTR evnt_parent; /* Major event name */
SLONG evnt_count; /* Current event count */
USHORT evnt_length; /* Length of event name */
TEXT evnt_name[1]; /* Event name */
};
typedef evnt *EVNT;
2001-05-23 15:26:42 +02:00
/* Request block */
struct evt_req {
event_hdr req_header;
2001-05-23 15:26:42 +02:00
SRQ req_requests; /* Request que owned by session block */
PTR req_process; /* Parent process block */
PTR req_session; /* Parent session block */
PTR req_interests; /* First interest in request */
2003-12-22 11:00:59 +01:00
FPTR_EVENT_CALLBACK req_ast; /* Asynchronous routine */
2001-05-23 15:26:42 +02:00
void *req_ast_arg; /* Argument for ast */
SLONG req_request_id; /* Request id, dummy */
};
typedef evt_req *EVT_REQ;
2001-05-23 15:26:42 +02:00
/* Request interest block */
struct rint {
event_hdr rint_header;
2001-05-23 15:26:42 +02:00
SRQ rint_interests; /* Que owned by event */
PTR rint_event; /* Event of interest */
PTR rint_request; /* Request of interest */
PTR rint_next; /* Next interest of request */
SLONG rint_count; /* Threshhold count */
};
typedef rint *RINT;
2001-05-23 15:26:42 +02:00
2004-04-29 13:16:31 +02:00
const int EPB_version1 = 1;
2004-02-02 12:02:12 +01:00
#endif // JRD_EVENT_H