8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-02-01 00:43:03 +01:00
firebird-mirror/src/jrd/sch.cpp

107 lines
2.5 KiB
C++
Raw Normal View History

2001-05-23 15:26:42 +02:00
/*
* PROGRAM: JRD Access Method
* MODULE: sch.cpp
2001-05-23 15:26:42 +02:00
* DESCRIPTION: Voluntary thread scheduler
*
* 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): ______________________________________.
2002-10-30 07:40:58 +01:00
*
* 2002.10.29 Sean Leyne - Removed obsolete "Netware" port
*
2001-05-23 15:26:42 +02:00
*/
#include "firebird.h"
2004-04-29 00:43:34 +02:00
#include <stdio.h>
2001-05-23 15:26:42 +02:00
#include <stdlib.h>
#include "../jrd/common.h"
2008-01-16 10:48:41 +01:00
#include "../jrd/ThreadStart.h"
2001-05-23 15:26:42 +02:00
#include "../jrd/isc.h"
2003-11-08 17:40:17 +01:00
#include "../jrd/ibase.h"
2001-05-23 15:26:42 +02:00
#include "../jrd/gds_proto.h"
#include "../jrd/isc_s_proto.h"
#include "../jrd/sch_proto.h"
#include "../jrd/thread_proto.h"
2001-05-23 15:26:42 +02:00
#include "../jrd/err_proto.h"
#include "../jrd/iberr_proto.h"
#include "../jrd/gdsassert.h"
#include "../jrd/os/thd_priority.h"
2003-12-14 05:33:51 +01:00
#include "../common/classes/locks.h"
#include "../common/classes/init.h"
2001-05-23 15:26:42 +02:00
#ifdef WIN_NT
#include <windows.h>
#endif
static FB_THREAD_ID thread_id = 0;
static Firebird::GlobalPtr<Firebird::Mutex> thread_mutex;
2001-05-23 15:26:42 +02:00
int API_ROUTINE gds__thread_enable(int enable_flag)
{
/**************************************
*
* g d s _ $ t h r e a d _ e n a b l e
*
**************************************
*
* Functional description
* Check-in with thread traffic cop.
*
**************************************/
2008-01-16 10:48:41 +01:00
return true;
2001-05-23 15:26:42 +02:00
}
2008-01-16 10:48:41 +01:00
void API_ROUTINE gds__thread_enter()
2001-05-23 15:26:42 +02:00
{
/**************************************
*
* g d s _ $ t h r e a d _ e n t e r
*
**************************************
*
* Functional description
* Check-in with thread traffic cop.
*
**************************************/
thread_mutex->enter();
fb_assert(!thread_id);
thread_id = getThreadId();
2001-05-23 15:26:42 +02:00
}
2008-01-16 10:48:41 +01:00
void API_ROUTINE gds__thread_exit()
2001-05-23 15:26:42 +02:00
{
/**************************************
*
* g d s _ $ t h r e a d _ e x i t
*
**************************************
*
* Functional description
* Check-out with thread traffic cop.
*
**************************************/
fb_assert(thread_id == getThreadId());
thread_id = 0;
thread_mutex->leave();
2001-05-23 15:26:42 +02:00
}