Kaydet (Commit) d911673a authored tarafından Thorsten Behrens's avatar Thorsten Behrens

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
üst 2d655683
...@@ -188,7 +188,6 @@ $(eval $(call gb_Library_add_cobjects,sal,\ ...@@ -188,7 +188,6 @@ $(eval $(call gb_Library_add_cobjects,sal,\
sal/osl/unx/profile \ sal/osl/unx/profile \
sal/osl/unx/readwrite_helper \ sal/osl/unx/readwrite_helper \
sal/osl/unx/security \ sal/osl/unx/security \
sal/osl/unx/semaphor \
sal/osl/unx/socket \ sal/osl/unx/socket \
sal/osl/unx/system \ sal/osl/unx/system \
sal/osl/unx/tempfile \ sal/osl/unx/tempfile \
...@@ -258,7 +257,6 @@ $(eval $(call gb_Library_add_cobjects,sal,\ ...@@ -258,7 +257,6 @@ $(eval $(call gb_Library_add_cobjects,sal,\
sal/osl/w32/nlsupport \ sal/osl/w32/nlsupport \
sal/osl/w32/pipe \ sal/osl/w32/pipe \
sal/osl/w32/security \ sal/osl/w32/security \
sal/osl/w32/semaphor \
sal/osl/w32/thread \ sal/osl/w32/thread \
sal/osl/w32/time \ sal/osl/w32/time \
sal/osl/w32/util \ sal/osl/w32/util \
......
...@@ -52,8 +52,6 @@ $(eval $(call gb_Package_add_file,sal_inc,inc/osl/profile.hxx,osl/profile.hxx)) ...@@ -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_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.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/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/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_decl.hxx,osl/socket_decl.hxx))
$(eval $(call gb_Package_add_file,sal_inc,inc/osl/socket.h,osl/socket.h)) $(eval $(call gb_Package_add_file,sal_inc,inc/osl/socket.h,osl/socket.h))
......
/* -*- 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.<BR>
@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: */
/* -*- 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 <osl/semaphor.h>
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.<BR>
@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: */
/* -*- 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 <osl/semaphor.h>
#include <osl/diagnose.h>
/* 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: */
...@@ -207,75 +207,6 @@ int macxp_resolveAlias(char *path, int buflen) ...@@ -207,75 +207,6 @@ int macxp_resolveAlias(char *path, int buflen)
#endif /* NO_PTHREAD_RTL */ #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) #if defined(FREEBSD)
char *fcvt(double value, int ndigit, int *decpt, int *sign) char *fcvt(double value, int ndigit, int *decpt, int *sign)
{ {
......
...@@ -73,7 +73,6 @@ ...@@ -73,7 +73,6 @@
# include <dlfcn.h> # include <dlfcn.h>
# include <endian.h> # include <endian.h>
# include <sys/time.h> # include <sys/time.h>
# include <semaphore.h>
# if __BYTE_ORDER == __LITTLE_ENDIAN # if __BYTE_ORDER == __LITTLE_ENDIAN
# define _LITTLE_ENDIAN # define _LITTLE_ENDIAN
# elif __BYTE_ORDER == __BIG_ENDIAN # elif __BYTE_ORDER == __BIG_ENDIAN
...@@ -103,7 +102,6 @@ ...@@ -103,7 +102,6 @@
# include <dlfcn.h> # include <dlfcn.h>
# include <endian.h> # include <endian.h>
# include <sys/time.h> # include <sys/time.h>
# include <semaphore.h>
# define IORESOURCE_TRANSFER_BSD # define IORESOURCE_TRANSFER_BSD
# define IOCHANNEL_TRANSFER_BSD_RENO # define IOCHANNEL_TRANSFER_BSD_RENO
# define pthread_testcancel() # define pthread_testcancel()
...@@ -118,7 +116,6 @@ ...@@ -118,7 +116,6 @@
# define ETIME ETIMEDOUT # define ETIME ETIMEDOUT
# include <pthread.h> # include <pthread.h>
# include <sys/sem.h> # include <sys/sem.h>
# include <semaphore.h>
# include <dlfcn.h> # include <dlfcn.h>
# include <sys/filio.h> # include <sys/filio.h>
# include <sys/ioctl.h> # include <sys/ioctl.h>
...@@ -148,7 +145,6 @@ ...@@ -148,7 +145,6 @@
# define ETIME ETIMEDOUT # define ETIME ETIMEDOUT
# include <pthread.h> # include <pthread.h>
# include <sys/sem.h> # include <sys/sem.h>
# include <semaphore.h>
# include <dlfcn.h> # include <dlfcn.h>
# include <sys/filio.h> # include <sys/filio.h>
# include <sys/ioctl.h> # include <sys/ioctl.h>
...@@ -173,7 +169,6 @@ ...@@ -173,7 +169,6 @@
# define ETIME ETIMEDOUT # define ETIME ETIMEDOUT
# include <pthread.h> # include <pthread.h>
# include <sys/sem.h> # include <sys/sem.h>
# include <semaphore.h>
# include <dlfcn.h> # include <dlfcn.h>
# include <sys/filio.h> # include <sys/filio.h>
# include <sys/ioctl.h> # include <sys/ioctl.h>
...@@ -208,7 +203,6 @@ ...@@ -208,7 +203,6 @@
# endif # endif
# define SLEEP_TIMESPEC(timespec) nsleep(&timespec, 0) # define SLEEP_TIMESPEC(timespec) nsleep(&timespec, 0)
# define LIBPATH "LIBPATH" # define LIBPATH "LIBPATH"
# define NO_PTHREAD_SEMAPHORES
#endif #endif
#ifdef SOLARIS #ifdef SOLARIS
...@@ -216,7 +210,6 @@ ...@@ -216,7 +210,6 @@
# include <sys/un.h> # include <sys/un.h>
# include <stropts.h> # include <stropts.h>
# include <pthread.h> # include <pthread.h>
# include <semaphore.h>
# include <netinet/tcp.h> # include <netinet/tcp.h>
# include <sys/filio.h> # include <sys/filio.h>
# include <dlfcn.h> # include <dlfcn.h>
...@@ -243,7 +236,6 @@ ...@@ -243,7 +236,6 @@
# include <netinet/tcp.h> # include <netinet/tcp.h>
# include <machine/endian.h> # include <machine/endian.h>
# include <sys/time.h> # include <sys/time.h>
# include <sys/semaphore.h>
/* fixme are premac and postmac still needed here? */ /* fixme are premac and postmac still needed here? */
# include <premac.h> # include <premac.h>
# include <mach-o/dyld.h> # include <mach-o/dyld.h>
...@@ -283,7 +275,6 @@ int macxp_resolveAlias(char *path, int buflen); ...@@ -283,7 +275,6 @@ int macxp_resolveAlias(char *path, int buflen);
# include <netinet/tcp.h> # include <netinet/tcp.h>
# include <machine/endian.h> # include <machine/endian.h>
# include <sys/time.h> # include <sys/time.h>
# include <sys/semaphore.h>
# if BYTE_ORDER == LITTLE_ENDIAN # if BYTE_ORDER == LITTLE_ENDIAN
# ifndef _LITTLE_ENDIAN # ifndef _LITTLE_ENDIAN
# define _LITTLE_ENDIAN # define _LITTLE_ENDIAN
...@@ -403,22 +394,6 @@ typedef struct sockaddr_ipx { ...@@ -403,22 +394,6 @@ typedef struct sockaddr_ipx {
/* END HACK */ /* 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 #ifdef NO_PTHREAD_RTL
#if !defined FREEBSD || (__FreeBSD_version < 500112) #if !defined FREEBSD || (__FreeBSD_version < 500112)
#if !defined NETBSD #if !defined NETBSD
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <osl/thread.h> #include <osl/thread.h>
#include <osl/mutex.h> #include <osl/mutex.h>
#include <osl/semaphor.h>
#include <osl/conditn.h> #include <osl/conditn.h>
#include <osl/interlck.h> #include <osl/interlck.h>
#include <osl/process.h> #include <osl/process.h>
......
/* -*- 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 <osl/diagnose.h>
#include <osl/semaphor.h>
/*
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: */
...@@ -53,7 +53,6 @@ osl/socket ; osl_AcceptorSocket ...@@ -53,7 +53,6 @@ osl/socket ; osl_AcceptorSocket
osl/mutex ; osl_Mutex osl/mutex ; osl_Mutex
osl/pipe ; osl_Pipe osl/pipe ; osl_Pipe
osl/semaphore ; osl_Semaphore
osl/condition ; osl_Condition osl/condition ; osl_Condition
osl/module ; osl_Module osl/module ; osl_Module
osl/security ; osl_Security osl/security ; osl_Security
......
...@@ -29,10 +29,6 @@ ...@@ -29,10 +29,6 @@
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <osl/pipe.hxx> #include <osl/pipe.hxx>
#ifndef _OSL_SEMAPHOR_HXX_
#include <osl/semaphor.hxx>
#endif
#ifndef _OSL_CONDITION_HXX_ #ifndef _OSL_CONDITION_HXX_
#include <osl/conditn.hxx> #include <osl/conditn.hxx>
#endif #endif
......
...@@ -25,7 +25,6 @@ UDK_3_0_0 { ...@@ -25,7 +25,6 @@ UDK_3_0_0 {
osl_acquireSocket; osl_acquireSocket;
osl_acquirePipe; osl_acquirePipe;
osl_acquireMutex; osl_acquireMutex;
osl_acquireSemaphore;
osl_addSignalHandler; osl_addSignalHandler;
osl_addToSocketSet; osl_addToSocketSet;
osl_assertFailedLine; osl_assertFailedLine;
...@@ -47,7 +46,6 @@ UDK_3_0_0 { ...@@ -47,7 +46,6 @@ UDK_3_0_0 {
osl_createInetSocketAddr; osl_createInetSocketAddr;
osl_createMutex; osl_createMutex;
osl_createPipe; osl_createPipe;
osl_createSemaphore;
osl_createSocket; osl_createSocket;
osl_createSocketSet; osl_createSocketSet;
osl_createSuspendedThread; osl_createSuspendedThread;
...@@ -58,7 +56,6 @@ UDK_3_0_0 { ...@@ -58,7 +56,6 @@ UDK_3_0_0 {
osl_destroyCondition; osl_destroyCondition;
osl_destroyHostAddr; osl_destroyHostAddr;
osl_destroyMutex; osl_destroyMutex;
osl_destroySemaphore;
osl_destroySocketAddr; osl_destroySocketAddr;
osl_destroySocketSet; osl_destroySocketSet;
osl_destroyThread; osl_destroyThread;
...@@ -144,7 +141,6 @@ UDK_3_0_0 { ...@@ -144,7 +141,6 @@ UDK_3_0_0 {
osl_releaseDirectoryItem; osl_releaseDirectoryItem;
osl_releaseMutex; osl_releaseMutex;
osl_releasePipe; osl_releasePipe;
osl_releaseSemaphore;
osl_releaseSocket; osl_releaseSocket;
osl_removeFromSocketSet; osl_removeFromSocketSet;
osl_removeProfileEntry; osl_removeProfileEntry;
...@@ -173,7 +169,6 @@ UDK_3_0_0 { ...@@ -173,7 +169,6 @@ UDK_3_0_0 {
osl_terminateThread; osl_terminateThread;
osl_trace; osl_trace;
osl_tryToAcquireMutex; osl_tryToAcquireMutex;
osl_tryToAcquireSemaphore;
osl_unloadModule; osl_unloadModule;
osl_waitCondition; osl_waitCondition;
osl_waitThread; osl_waitThread;
......
...@@ -30,10 +30,7 @@ $(eval $(call gb_Package_Package,salhelper_inc,$(SRCDIR)/salhelper/inc/salhelper ...@@ -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/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/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/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/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/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/simplereferenceobject.hxx,simplereferenceobject.hxx))
$(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/singletonref.hxx,singletonref.hxx)) $(eval $(call gb_Package_add_file,salhelper_inc,inc/salhelper/singletonref.hxx,singletonref.hxx))
......
/* -*- 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 <sal/types.h>
#include <osl/diagnose.h>
#include <osl/conditn.hxx>
#include <salhelper/refobj.hxx>
namespace salhelper
{
//----------------------------------------------------------------------------
#ifndef SALHELPER_COPYCTOR_API
#define SALHELPER_COPYCTOR_API(C) C (const C&); C& operator= (const C&)
#endif
//----------------------------------------------------------------------------
template<class value_type>
class FutureValue : protected osl::Condition
{
/** Representation.
*/
value_type m_aValue;
/** Not implemented.
*/
SALHELPER_COPYCTOR_API(FutureValue<value_type>);
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<FutureValue*>(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 value_type>
class Future : public salhelper::ReferenceObject
{
/** Representation.
*/
FutureValue<value_type> m_aValue;
/** Not implemented.
*/
SALHELPER_COPYCTOR_API(Future<value_type>);
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: */
/* -*- 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 <sal/types.h>
#include <rtl/ref.hxx>
#include <osl/mutex.hxx>
#include <salhelper/future.hxx>
#include <salhelper/queue.hxx>
namespace salhelper
{
//----------------------------------------------------------------------------
#ifndef SALHELPER_COPYCTOR_API
#define SALHELPER_COPYCTOR_API(C) C (const C&); C& operator= (const C&)
#endif
//----------------------------------------------------------------------------
template<class element_type>
class FutureQueue : protected osl::Mutex
{
/** Representation.
*/
typedef salhelper::Future<element_type> future_type;
salhelper::QueueBase< rtl::Reference<future_type> > m_aDelayed;
salhelper::QueueBase< rtl::Reference<future_type> > m_aPresent;
/** Not implemented.
*/
SALHELPER_COPYCTOR_API(FutureQueue<element_type>);
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<future_type> 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<element_type> > get()
{
osl::MutexGuard aGuard (*this);
rtl::Reference<future_type> 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: */
/* -*- 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 <sal/types.h>
#include <osl/diagnose.h>
#include <osl/mutex.hxx>
#include <osl/semaphor.hxx>
#ifndef __LIST__
#include <list>
#endif
namespace salhelper
{
//----------------------------------------------------------------------------
#ifndef SALHELPER_COPYCTOR_API
#define SALHELPER_COPYCTOR_API(C) C (const C&); C& operator= (const C&)
#endif
//----------------------------------------------------------------------------
template<class element_type>
class QueueBase : protected std::list<element_type>
{
/** Representation.
*/
osl::Mutex m_aMutex;
/** Not implemented.
*/
SALHELPER_COPYCTOR_API(QueueBase<element_type>);
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 element_type>
class Queue : protected QueueBase<element_type>
{
/** Representation.
*/
osl::Semaphore m_aNotEmpty;
/** Not implemented.
*/
SALHELPER_COPYCTOR_API(Queue<element_type>);
public:
inline Queue() : m_aNotEmpty (static_cast< sal_uInt32 >(0))
{}
inline ~Queue()
{}
inline void put (const element_type& element)
{
QueueBase<element_type>::put (element);
m_aNotEmpty.release();
}
inline element_type get()
{
element_type element;
m_aNotEmpty.acquire();
element = QueueBase<element_type>::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 element_type>
class BoundedQueue : protected Queue<element_type>
{
/** Representation.
*/
osl::Semaphore m_aNotFull;
/** Not implemented.
*/
SALHELPER_COPYCTOR_API(BoundedQueue<element_type>);
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<element_type>::put (element);
}
inline element_type get()
{
element_type element;
element = Queue<element_type>::get();
m_aNotFull.release();
return (element);
}
};
//----------------------------------------------------------------------------
} // namespace salhelper
#endif /* !_SALHELPER_QUEUE_HXX_ */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment