From d911673a64250ece50f6ca5578385adabcae5e5d Mon Sep 17 00:00:00 2001 From: Thorsten Behrens Date: Tue, 4 Dec 2012 12:36:09 +0100 Subject: API CHANGE: remove long-deprecated Semaphore & related stuff. osl::semaphore was not portable & thusly long-deprecated. Also killing further unused clients of that code in salhelper. Change-Id: Ie1c1924e06e8ce3be33fd1dc2c6933f2de8b5217 --- sal/Library_sal.mk | 2 - sal/Package_inc.mk | 2 - sal/inc/osl/semaphor.h | 91 --------------- sal/inc/osl/semaphor.hxx | 120 ------------------- sal/osl/unx/semaphor.c | 126 -------------------- sal/osl/unx/system.c | 69 ----------- sal/osl/unx/system.h | 25 ---- sal/osl/w32/pipe.c | 1 - sal/osl/w32/semaphor.c | 104 ----------------- sal/qa/libs2test.txt | 1 - sal/qa/osl/condition/osl_Condition_Const.h | 4 - sal/util/sal.map | 5 - salhelper/Package_inc.mk | 3 - salhelper/inc/salhelper/future.hxx | 114 ------------------ salhelper/inc/salhelper/futurequeue.hxx | 102 ----------------- salhelper/inc/salhelper/queue.hxx | 178 ----------------------------- 16 files changed, 947 deletions(-) delete mode 100644 sal/inc/osl/semaphor.h delete mode 100644 sal/inc/osl/semaphor.hxx delete mode 100644 sal/osl/unx/semaphor.c delete mode 100644 sal/osl/w32/semaphor.c delete mode 100644 salhelper/inc/salhelper/future.hxx delete mode 100644 salhelper/inc/salhelper/futurequeue.hxx delete mode 100644 salhelper/inc/salhelper/queue.hxx diff --git a/sal/Library_sal.mk b/sal/Library_sal.mk index 9c835ed153cd..72234a9d1e3f 100644 --- a/sal/Library_sal.mk +++ b/sal/Library_sal.mk @@ -188,7 +188,6 @@ $(eval $(call gb_Library_add_cobjects,sal,\ sal/osl/unx/profile \ sal/osl/unx/readwrite_helper \ sal/osl/unx/security \ - sal/osl/unx/semaphor \ sal/osl/unx/socket \ sal/osl/unx/system \ sal/osl/unx/tempfile \ @@ -258,7 +257,6 @@ $(eval $(call gb_Library_add_cobjects,sal,\ sal/osl/w32/nlsupport \ sal/osl/w32/pipe \ sal/osl/w32/security \ - sal/osl/w32/semaphor \ sal/osl/w32/thread \ sal/osl/w32/time \ sal/osl/w32/util \ diff --git a/sal/Package_inc.mk b/sal/Package_inc.mk index bf17e5fead0c..0e91e08af0a4 100644 --- a/sal/Package_inc.mk +++ b/sal/Package_inc.mk @@ -52,8 +52,6 @@ $(eval $(call gb_Package_add_file,sal_inc,inc/osl/profile.hxx,osl/profile.hxx)) $(eval $(call gb_Package_add_file,sal_inc,inc/osl/security_decl.hxx,osl/security_decl.hxx)) $(eval $(call gb_Package_add_file,sal_inc,inc/osl/security.h,osl/security.h)) $(eval $(call gb_Package_add_file,sal_inc,inc/osl/security.hxx,osl/security.hxx)) -$(eval $(call gb_Package_add_file,sal_inc,inc/osl/semaphor.h,osl/semaphor.h)) -$(eval $(call gb_Package_add_file,sal_inc,inc/osl/semaphor.hxx,osl/semaphor.hxx)) $(eval $(call gb_Package_add_file,sal_inc,inc/osl/signal.h,osl/signal.h)) $(eval $(call gb_Package_add_file,sal_inc,inc/osl/socket_decl.hxx,osl/socket_decl.hxx)) $(eval $(call gb_Package_add_file,sal_inc,inc/osl/socket.h,osl/socket.h)) diff --git a/sal/inc/osl/semaphor.h b/sal/inc/osl/semaphor.h deleted file mode 100644 index 9d46d7f702c3..000000000000 --- a/sal/inc/osl/semaphor.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.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.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef _OSL_SEMAPHORE_H_ -#define _OSL_SEMAPHORE_H_ - -#include "sal/config.h" - -#include "sal/saldllapi.h" -#include "sal/types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void* oslSemaphore; - -/** Creates a semaphore.
- - @deprecated - Must not be used, as unnamed semaphores are not supported on Mac OS X. - - @param initialCount denotes the starting value the semaphore. If you set it to - zero, the first acquire() blocks. Otherwise InitialCount acquire()s are - immedeatly successfull. - @return 0 if the semaphore could not be created, otherwise a handle to the sem. -*/ -SAL_DLLPUBLIC oslSemaphore SAL_CALL osl_createSemaphore(sal_uInt32 initialCount); - -/** Release the OS-structures and free semaphore data-structure - - @deprecated - Must not be used, as unnamed semaphores are not supported on Mac OS X. - - @return fbbb -*/ -SAL_DLLPUBLIC void SAL_CALL osl_destroySemaphore(oslSemaphore Semaphore); - -/** acquire() decreases the count. It will block if it tries to - decrease below zero. - - @deprecated - Must not be used, as unnamed semaphores are not supported on Mac OS X. - - @return False if the system-call failed. -*/ -SAL_DLLPUBLIC sal_Bool SAL_CALL osl_acquireSemaphore(oslSemaphore Semaphore); - -/** tryToAcquire() tries to decreases the count. It will - return with False if it would decrease the count below zero. - (When acquire() would block.) If it could successfully - decrease the count, it will return True. - - @deprecated - Must not be used, as unnamed semaphores are not supported on Mac OS X. -*/ -SAL_DLLPUBLIC sal_Bool SAL_CALL osl_tryToAcquireSemaphore(oslSemaphore Semaphore); - -/** release() increases the count. - - @deprecated - Must not be used, as unnamed semaphores are not supported on Mac OS X. - - @return False if the system-call failed. -*/ -SAL_DLLPUBLIC sal_Bool SAL_CALL osl_releaseSemaphore(oslSemaphore Semaphore); - -#ifdef __cplusplus -} -#endif - -#endif /* _OSL_SEMAPHORE_H_ */ - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/inc/osl/semaphor.hxx b/sal/inc/osl/semaphor.hxx deleted file mode 100644 index 155b7b823e8b..000000000000 --- a/sal/inc/osl/semaphor.hxx +++ /dev/null @@ -1,120 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.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.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef _OSL_SEMAPHORE_HXX_ -#define _OSL_SEMAPHORE_HXX_ - -#ifdef __cplusplus - -#include - - -namespace osl -{ - /** C++ wrapper class around C semaphore functions. - - @deprecated - Must not be used, as unnamed semaphores are not supported on Mac OS X. - */ - class Semaphore { - - public: - - /** Creates a semaphore.
- @param initialCount denotes the starting value the semaphore. If you set it to - zero, the first acquire() blocks. Otherwise InitialCount acquire()s are - immedeatly successfull. - @return 0 if the semaphore could not be created, otherwise a handle to the sem. - */ - - Semaphore(sal_uInt32 initialCount) - { - semaphore = osl_createSemaphore(initialCount); - } - - /** Release the OS-structures and free semaphore data-structure - @return fbbb - */ - ~Semaphore() - { - osl_destroySemaphore(semaphore); - } - - /** acquire() decreases the count. It will block if it tries to - decrease below zero. - @return False if the system-call failed. - */ - sal_Bool acquire() - { - return osl_acquireSemaphore(semaphore); - } - - /** tryToAcquire() tries to decreases the count. It will - return with False if it would decrease the count below zero. - (When acquire() would block.) If it could successfully - decrease the count, it will return True. - */ - sal_Bool tryToAcquire() - { - return osl_tryToAcquireSemaphore(semaphore); - } - - /** release() increases the count. - @return False if the system-call failed. - */ - sal_Bool release() - { - return osl_releaseSemaphore(semaphore); - } - - private: - oslSemaphore semaphore; - - /** The underlying oslSemaphore has no reference count. - - Since the underlying oslSemaphore is not a reference counted object, copy - constructed Semaphore may work on an already destructed oslSemaphore object. - - */ - Semaphore(const Semaphore&); - - /** The underlying oslSemaphore has no reference count. - - When destructed, the Semaphore object destroys the undelying oslSemaphore, - which might cause severe problems in case it's a temporary object. - - */ - Semaphore(oslSemaphore Semaphore); - - /** This assignment operator is private for the same reason as - the copy constructor. - */ - Semaphore& operator= (const Semaphore&); - - /** This assignment operator is private for the same reason as - the constructor taking a oslSemaphore argument. - */ - Semaphore& operator= (oslSemaphore); - }; -} - -#endif /* __cplusplus */ -#endif /* _OSL_SEMAPHORE_HXX_ */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/unx/semaphor.c b/sal/osl/unx/semaphor.c deleted file mode 100644 index bff843f29725..000000000000 --- a/sal/osl/unx/semaphor.c +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.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.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "system.h" - -#include -#include - -/* This is the (default) POSIX thread-local semaphore variant */ - -/* - Implemetation notes: - The void* represented by oslSemaphore is used - as a pointer to an sem_t struct -*/ - -/*****************************************************************************/ -/* osl_createSemaphore */ -/*****************************************************************************/ - -oslSemaphore SAL_CALL osl_createSemaphore(sal_uInt32 initialCount) -{ - int ret = 0; - oslSemaphore Semaphore; - - Semaphore= malloc(sizeof(sem_t)); - - OSL_ASSERT(Semaphore); /* ptr valid? */ - - if ( Semaphore == 0 ) - { - return 0; - } - - /* unnamed semaphore, not shared between processes */ - - ret= sem_init((sem_t*)Semaphore, 0, initialCount); - - /* create failed? */ - if (ret != 0) - { - OSL_TRACE("osl_createSemaphore failed. Errno: %d; %s\n", - errno, - strerror(errno)); - - free(Semaphore); - Semaphore = NULL; - } - - return Semaphore; -} - -/*****************************************************************************/ -/* osl_destroySemaphore */ -/*****************************************************************************/ -void SAL_CALL osl_destroySemaphore(oslSemaphore Semaphore) -{ - if(Semaphore) /* ptr valid? */ - { - sem_destroy((sem_t*)Semaphore); - free(Semaphore); - } -} - -/*****************************************************************************/ -/* osl_acquireSemaphore */ -/*****************************************************************************/ -sal_Bool SAL_CALL osl_acquireSemaphore(oslSemaphore Semaphore) { - - OSL_ASSERT(Semaphore != 0); /* abort in debug mode */ - - if (Semaphore != 0) /* be tolerant in release mode */ - { - return (sem_wait((sem_t*)Semaphore) == 0); - } - - return sal_False; -} - -/*****************************************************************************/ -/* osl_tryToAcquireSemaphore */ -/*****************************************************************************/ -sal_Bool SAL_CALL osl_tryToAcquireSemaphore(oslSemaphore Semaphore) { - - OSL_ASSERT(Semaphore != 0); /* abort in debug mode */ - if (Semaphore != 0) /* be tolerant in release mode */ - { - return (sem_trywait((sem_t*)Semaphore) == 0); - } - - return sal_False; -} - -/*****************************************************************************/ -/* osl_releaseSemaphore */ -/*****************************************************************************/ -sal_Bool SAL_CALL osl_releaseSemaphore(oslSemaphore Semaphore) { - - OSL_ASSERT(Semaphore != 0); /* abort in debug mode */ - - if (Semaphore != 0) /* be tolerant in release mode */ - { - return (sem_post((sem_t*)Semaphore) == 0); - } - - return sal_False; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/unx/system.c b/sal/osl/unx/system.c index fca765566785..8c8280dff70c 100644 --- a/sal/osl/unx/system.c +++ b/sal/osl/unx/system.c @@ -207,75 +207,6 @@ int macxp_resolveAlias(char *path, int buflen) #endif /* NO_PTHREAD_RTL */ -#ifdef NO_PTHREAD_SEMAPHORES -int sem_init(sem_t* sem, int pshared, unsigned int value) -{ - (void)pshared; - pthread_mutex_init(&sem->mutex, PTHREAD_MUTEXATTR_DEFAULT); - pthread_cond_init(&sem->increased, PTHREAD_CONDATTR_DEFAULT); - - sem->value = (int)value; - return 0; -} - -int sem_destroy(sem_t* sem) -{ - pthread_mutex_destroy(&sem->mutex); - pthread_cond_destroy(&sem->increased); - sem->value = 0; - return 0; -} - -int sem_wait(sem_t* sem) -{ - pthread_mutex_lock(&sem->mutex); - - while (sem->value <= 0) - { - pthread_cond_wait(&sem->increased, &sem->mutex); - } - - sem->value--; - pthread_mutex_unlock(&sem->mutex); - - return 0; -} - -int sem_trywait(sem_t* sem) -{ - int result = 0; - - pthread_mutex_lock(&sem->mutex); - - if (sem->value > 0) - { - sem->value--; - } - else - { - errno = EAGAIN; - result = -1; - } - - pthread_mutex_unlock(&sem->mutex); - - return result; -} - -int sem_post(sem_t* sem) -{ - pthread_mutex_lock(&sem->mutex); - - sem->value++; - - pthread_mutex_unlock(&sem->mutex); - - pthread_cond_signal(&sem->increased); - - return 0; -} -#endif - #if defined(FREEBSD) char *fcvt(double value, int ndigit, int *decpt, int *sign) { diff --git a/sal/osl/unx/system.h b/sal/osl/unx/system.h index 8d7e734b6c6b..057257e691f6 100644 --- a/sal/osl/unx/system.h +++ b/sal/osl/unx/system.h @@ -73,7 +73,6 @@ # include # include # include -# include # if __BYTE_ORDER == __LITTLE_ENDIAN # define _LITTLE_ENDIAN # elif __BYTE_ORDER == __BIG_ENDIAN @@ -103,7 +102,6 @@ # include # include # include -# include # define IORESOURCE_TRANSFER_BSD # define IOCHANNEL_TRANSFER_BSD_RENO # define pthread_testcancel() @@ -118,7 +116,6 @@ # define ETIME ETIMEDOUT # include # include -# include # include # include # include @@ -148,7 +145,6 @@ # define ETIME ETIMEDOUT # include # include -# include # include # include # include @@ -173,7 +169,6 @@ # define ETIME ETIMEDOUT # include # include -# include # include # include # include @@ -208,7 +203,6 @@ # endif # define SLEEP_TIMESPEC(timespec) nsleep(×pec, 0) # define LIBPATH "LIBPATH" -# define NO_PTHREAD_SEMAPHORES #endif #ifdef SOLARIS @@ -216,7 +210,6 @@ # include # include # include -# include # include # include # include @@ -243,7 +236,6 @@ # include # include # include -# include /* fixme are premac and postmac still needed here? */ # include # include @@ -283,7 +275,6 @@ int macxp_resolveAlias(char *path, int buflen); # include # include # include -# include # if BYTE_ORDER == LITTLE_ENDIAN # ifndef _LITTLE_ENDIAN # define _LITTLE_ENDIAN @@ -403,22 +394,6 @@ typedef struct sockaddr_ipx { /* END HACK */ -#ifdef NO_PTHREAD_SEMAPHORES - -typedef struct -{ - pthread_mutex_t mutex; - pthread_cond_t increased; - int value; -} sem_t; -extern int sem_init(sem_t* sem, int pshared, unsigned int value); -extern int sem_destroy(sem_t* sem); -extern int sem_wait(sem_t* sem); -extern int sem_trywait(sem_t* sem); -extern int sem_post(sem_t* sem); - -#endif - #ifdef NO_PTHREAD_RTL #if !defined FREEBSD || (__FreeBSD_version < 500112) #if !defined NETBSD diff --git a/sal/osl/w32/pipe.c b/sal/osl/w32/pipe.c index 62125b9ddb81..149de07f73ce 100644 --- a/sal/osl/w32/pipe.c +++ b/sal/osl/w32/pipe.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/sal/osl/w32/semaphor.c b/sal/osl/w32/semaphor.c deleted file mode 100644 index de3828b31e8f..000000000000 --- a/sal/osl/w32/semaphor.c +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.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.apache.org/licenses/LICENSE-2.0 . - */ - -#include "system.h" - -#include -#include - -/* - Implemetation notes: - The void* represented by oslSemaphore is used - to store a WIN32 HANDLE. -*/ - - -/*****************************************************************************/ -/* osl_createSemaphore */ -/*****************************************************************************/ -oslSemaphore SAL_CALL osl_createSemaphore(sal_uInt32 initialCount) -{ - oslSemaphore Semaphore; - - Semaphore= CreateSemaphore(0, initialCount, INT_MAX, 0); - - /* create failed? */ - if((HANDLE)Semaphore == INVALID_HANDLE_VALUE) - { - Semaphore= 0; - } - - return Semaphore; -} - -/*****************************************************************************/ -/* osl_destroySemaphore */ -/*****************************************************************************/ -void SAL_CALL osl_destroySemaphore(oslSemaphore Semaphore) -{ - - - if(Semaphore != 0) - { - CloseHandle((HANDLE)Semaphore); - } - -} - -/*****************************************************************************/ -/* osl_acquireSemaphore */ -/*****************************************************************************/ -sal_Bool SAL_CALL osl_acquireSemaphore(oslSemaphore Semaphore) -{ - OSL_ASSERT(Semaphore != 0); - - switch ( WaitForSingleObject( (HANDLE)Semaphore, INFINITE ) ) - { - case WAIT_OBJECT_0: - return sal_True; - - default: - return (sal_False); - } -} - -/*****************************************************************************/ -/* osl_tryToAcquireSemaphore */ -/*****************************************************************************/ -sal_Bool SAL_CALL osl_tryToAcquireSemaphore(oslSemaphore Semaphore) -{ - OSL_ASSERT(Semaphore != 0); - return (sal_Bool)(WaitForSingleObject((HANDLE)Semaphore, 0) == WAIT_OBJECT_0); -} - - -/*****************************************************************************/ -/* osl_releaseSemaphore */ -/*****************************************************************************/ -sal_Bool SAL_CALL osl_releaseSemaphore(oslSemaphore Semaphore) -{ - OSL_ASSERT(Semaphore != 0); - - /* increase count by one, not interested in previous count */ - return (sal_Bool)(ReleaseSemaphore((HANDLE)Semaphore, 1, NULL) != FALSE); -} - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/qa/libs2test.txt b/sal/qa/libs2test.txt index 2f8a01fb592d..d41bf062f491 100644 --- a/sal/qa/libs2test.txt +++ b/sal/qa/libs2test.txt @@ -53,7 +53,6 @@ osl/socket ; osl_AcceptorSocket osl/mutex ; osl_Mutex osl/pipe ; osl_Pipe -osl/semaphore ; osl_Semaphore osl/condition ; osl_Condition osl/module ; osl_Module osl/security ; osl_Security diff --git a/sal/qa/osl/condition/osl_Condition_Const.h b/sal/qa/osl/condition/osl_Condition_Const.h index 9443ec359c60..6101914fa9a6 100644 --- a/sal/qa/osl/condition/osl_Condition_Const.h +++ b/sal/qa/osl/condition/osl_Condition_Const.h @@ -29,10 +29,6 @@ #include #include -#ifndef _OSL_SEMAPHOR_HXX_ -#include -#endif - #ifndef _OSL_CONDITION_HXX_ #include #endif diff --git a/sal/util/sal.map b/sal/util/sal.map index 3c5e787ed35a..47dfe39897bd 100644 --- a/sal/util/sal.map +++ b/sal/util/sal.map @@ -25,7 +25,6 @@ UDK_3_0_0 { osl_acquireSocket; osl_acquirePipe; osl_acquireMutex; - osl_acquireSemaphore; osl_addSignalHandler; osl_addToSocketSet; osl_assertFailedLine; @@ -47,7 +46,6 @@ UDK_3_0_0 { osl_createInetSocketAddr; osl_createMutex; osl_createPipe; - osl_createSemaphore; osl_createSocket; osl_createSocketSet; osl_createSuspendedThread; @@ -58,7 +56,6 @@ UDK_3_0_0 { osl_destroyCondition; osl_destroyHostAddr; osl_destroyMutex; - osl_destroySemaphore; osl_destroySocketAddr; osl_destroySocketSet; osl_destroyThread; @@ -144,7 +141,6 @@ UDK_3_0_0 { osl_releaseDirectoryItem; osl_releaseMutex; osl_releasePipe; - osl_releaseSemaphore; osl_releaseSocket; osl_removeFromSocketSet; osl_removeProfileEntry; @@ -173,7 +169,6 @@ UDK_3_0_0 { osl_terminateThread; osl_trace; osl_tryToAcquireMutex; - osl_tryToAcquireSemaphore; osl_unloadModule; osl_waitCondition; osl_waitThread; diff --git a/salhelper/Package_inc.mk b/salhelper/Package_inc.mk index 4950c69d7311..7a30c7fc967d 100644 --- a/salhelper/Package_inc.mk +++ b/salhelper/Package_inc.mk @@ -30,10 +30,7 @@ $(eval $(call gb_Package_Package,salhelper_inc,$(SRCDIR)/salhelper/inc/salhelper $(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/salhelperdllapi.h,salhelperdllapi.h)) $(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/condition.hxx,condition.hxx)) $(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/dynload.hxx,dynload.hxx)) -$(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/future.hxx,future.hxx)) -$(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/futurequeue.hxx,futurequeue.hxx)) $(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/linkhelper.hxx,linkhelper.hxx)) -$(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/queue.hxx,queue.hxx)) $(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/refobj.hxx,refobj.hxx)) $(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/simplereferenceobject.hxx,simplereferenceobject.hxx)) $(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/singletonref.hxx,singletonref.hxx)) diff --git a/salhelper/inc/salhelper/future.hxx b/salhelper/inc/salhelper/future.hxx deleted file mode 100644 index 0b97fd158ab6..000000000000 --- a/salhelper/inc/salhelper/future.hxx +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.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.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef _SALHELPER_FUTURE_HXX_ -#define _SALHELPER_FUTURE_HXX_ - -#include -#include -#include -#include - -namespace salhelper -{ - -//---------------------------------------------------------------------------- - -#ifndef SALHELPER_COPYCTOR_API -#define SALHELPER_COPYCTOR_API(C) C (const C&); C& operator= (const C&) -#endif - -//---------------------------------------------------------------------------- - -template -class FutureValue : protected osl::Condition -{ - /** Representation. - */ - value_type m_aValue; - - /** Not implemented. - */ - SALHELPER_COPYCTOR_API(FutureValue); - -public: - inline FutureValue (const value_type& value = value_type()) SAL_THROW(()) - : m_aValue (value) - { - Condition::reset(); - } - - inline ~FutureValue() SAL_THROW(()) - {} - - inline sal_Bool is() const SAL_THROW(()) - { - return const_cast(this)->check(); - } - - inline void set (const value_type& value) SAL_THROW(()) - { - m_aValue = value; - Condition::set(); - } - - inline value_type& get() SAL_THROW(()) - { - Condition::wait(); - return m_aValue; - } -}; - -//---------------------------------------------------------------------------- - -template -class Future : public salhelper::ReferenceObject -{ - /** Representation. - */ - FutureValue m_aValue; - - /** Not implemented. - */ - SALHELPER_COPYCTOR_API(Future); - -public: - inline Future (const value_type& value = value_type()) SAL_THROW(()) - : m_aValue (value) - {} - - inline void set (const value_type& value) SAL_THROW(()) - { - OSL_PRECOND(!m_aValue.is(), "Future::set(): value already set"); - m_aValue.set (value); - } - - inline value_type& get() SAL_THROW(()) - { - return m_aValue.get(); - } -}; - -//---------------------------------------------------------------------------- - -} // namespace salhelper - -#endif /* !_SALHELPER_FUTURE_HXX_ */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/salhelper/inc/salhelper/futurequeue.hxx b/salhelper/inc/salhelper/futurequeue.hxx deleted file mode 100644 index c54a6a335a92..000000000000 --- a/salhelper/inc/salhelper/futurequeue.hxx +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.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.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef _SALHELPER_FUTUREQUEUE_HXX_ -#define _SALHELPER_FUTUREQUEUE_HXX_ - -#include -#include -#include -#include -#include - -namespace salhelper -{ - -//---------------------------------------------------------------------------- - -#ifndef SALHELPER_COPYCTOR_API -#define SALHELPER_COPYCTOR_API(C) C (const C&); C& operator= (const C&) -#endif - -//---------------------------------------------------------------------------- - -template -class FutureQueue : protected osl::Mutex -{ - /** Representation. - */ - typedef salhelper::Future future_type; - - salhelper::QueueBase< rtl::Reference > m_aDelayed; - salhelper::QueueBase< rtl::Reference > m_aPresent; - - /** Not implemented. - */ - SALHELPER_COPYCTOR_API(FutureQueue); - -public: - /** Construction. - */ - inline FutureQueue() - {} - - /** Destruction. - */ - inline ~FutureQueue() - {} - - /** Enqueue element at queue tail. - */ - inline void put (const element_type& element) - { - osl::MutexGuard aGuard (*this); - - rtl::Reference xFuture (m_aDelayed.get()); - if (!xFuture.is()) - { - xFuture = new future_type(); - m_aPresent.put (xFuture); - } - xFuture->set (element); - } - - /** Dequeue a future to element at queue head. - */ - inline rtl::Reference< salhelper::Future > get() - { - osl::MutexGuard aGuard (*this); - - rtl::Reference xFuture (m_aPresent.get()); - if (!xFuture.is()) - { - xFuture = new future_type(); - m_aDelayed.put (xFuture); - } - return (xFuture); - } -}; - -//---------------------------------------------------------------------------- - -} // namespace salhelper - -#endif /* !_SALHELPER_FUTUREQUEUE */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/salhelper/inc/salhelper/queue.hxx b/salhelper/inc/salhelper/queue.hxx deleted file mode 100644 index 444b09fb5037..000000000000 --- a/salhelper/inc/salhelper/queue.hxx +++ /dev/null @@ -1,178 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.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.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef _SALHELPER_QUEUE_HXX_ -#define _SALHELPER_QUEUE_HXX_ - -#include -#include -#include -#include - -#ifndef __LIST__ -#include -#endif - -namespace salhelper -{ - -//---------------------------------------------------------------------------- - -#ifndef SALHELPER_COPYCTOR_API -#define SALHELPER_COPYCTOR_API(C) C (const C&); C& operator= (const C&) -#endif - -//---------------------------------------------------------------------------- - -template -class QueueBase : protected std::list -{ - /** Representation. - */ - osl::Mutex m_aMutex; - - /** Not implemented. - */ - SALHELPER_COPYCTOR_API(QueueBase); - -public: - inline QueueBase() - {} - - inline ~QueueBase() - { - erase (this->begin(), this->end()); - } - - inline void put (const element_type& element) - { - osl::MutexGuard aGuard (m_aMutex); - push_back (element); - } - - inline element_type get() - { - element_type element; - - osl::MutexGuard aGuard (m_aMutex); - if (!this->empty()) - { - element = this->front(); - this->pop_front(); - } - - return (element); - } -}; - -//---------------------------------------------------------------------------- - -/** Queue. - - @deprecated - Must not be used, as it internally uses unnamed semaphores, which are not - supported on Mac OS X. -*/ -template -class Queue : protected QueueBase -{ - /** Representation. - */ - osl::Semaphore m_aNotEmpty; - - /** Not implemented. - */ - SALHELPER_COPYCTOR_API(Queue); - -public: - inline Queue() : m_aNotEmpty (static_cast< sal_uInt32 >(0)) - {} - - inline ~Queue() - {} - - inline void put (const element_type& element) - { - QueueBase::put (element); - m_aNotEmpty.release(); - } - - inline element_type get() - { - element_type element; - - m_aNotEmpty.acquire(); - element = QueueBase::get(); - - return (element); - } -}; - -//---------------------------------------------------------------------------- - -/** Bounded queue. - - @deprecated - Must not be used, as it internally uses unnamed semaphores, which are not - supported on Mac OS X. -*/ -template -class BoundedQueue : protected Queue -{ - /** Representation. - */ - osl::Semaphore m_aNotFull; - - /** Not implemented. - */ - SALHELPER_COPYCTOR_API(BoundedQueue); - -public: - inline BoundedQueue (sal_uInt32 capacity) : m_aNotFull (capacity) - { - OSL_POSTCOND(capacity, "BoundedQueue:BoundedQueue(): no capacity"); - } - - inline ~BoundedQueue() - {} - - inline void put (const element_type& element) - { - m_aNotFull.acquire(); - Queue::put (element); - } - - inline element_type get() - { - element_type element; - - element = Queue::get(); - m_aNotFull.release(); - - return (element); - } -}; - -//---------------------------------------------------------------------------- - -} // namespace salhelper - -#endif /* !_SALHELPER_QUEUE_HXX_ */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3