aboutsummaryrefslogtreecommitdiffstats
path: root/libparc/parc/concurrent
diff options
context:
space:
mode:
Diffstat (limited to 'libparc/parc/concurrent')
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_AtomicUint16.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_AtomicUint16.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_AtomicUint32.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_AtomicUint32.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_AtomicUint64.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_AtomicUint64.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_AtomicUint8.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_AtomicUint8.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_FutureTask.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_FutureTask.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Lock.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Lock.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Notifier.c26
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Notifier.h1
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_RingBuffer.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_RingBuffer.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_RingBuffer_1x1.c13
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_RingBuffer_1x1.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_RingBuffer_NxM.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_RingBuffer_NxM.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_ScheduledTask.c7
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_ScheduledTask.h0
-rw-r--r--libparc/parc/concurrent/parc_ScheduledThreadPool.c2
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_ScheduledThreadPool.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Synchronizer.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Synchronizer.h0
-rw-r--r--libparc/parc/concurrent/parc_Thread.c6
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Thread.h0
-rw-r--r--libparc/parc/concurrent/parc_ThreadPool.c2
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_ThreadPool.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Timeout.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Timer.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Timer.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/test/test_parc_Notifier.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/test/test_parc_RingBuffer_1x1.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/test/test_parc_RingBuffer_NxM.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/test/test_parc_Synchronizer.c0
37 files changed, 38 insertions, 19 deletions
diff --git a/libparc/parc/concurrent/parc_AtomicUint16.c b/libparc/parc/concurrent/parc_AtomicUint16.c
index 9bf2e478..9bf2e478 100755..100644
--- a/libparc/parc/concurrent/parc_AtomicUint16.c
+++ b/libparc/parc/concurrent/parc_AtomicUint16.c
diff --git a/libparc/parc/concurrent/parc_AtomicUint16.h b/libparc/parc/concurrent/parc_AtomicUint16.h
index ff6a4fc3..ff6a4fc3 100755..100644
--- a/libparc/parc/concurrent/parc_AtomicUint16.h
+++ b/libparc/parc/concurrent/parc_AtomicUint16.h
diff --git a/libparc/parc/concurrent/parc_AtomicUint32.c b/libparc/parc/concurrent/parc_AtomicUint32.c
index 24093951..24093951 100755..100644
--- a/libparc/parc/concurrent/parc_AtomicUint32.c
+++ b/libparc/parc/concurrent/parc_AtomicUint32.c
diff --git a/libparc/parc/concurrent/parc_AtomicUint32.h b/libparc/parc/concurrent/parc_AtomicUint32.h
index 870cbe80..870cbe80 100755..100644
--- a/libparc/parc/concurrent/parc_AtomicUint32.h
+++ b/libparc/parc/concurrent/parc_AtomicUint32.h
diff --git a/libparc/parc/concurrent/parc_AtomicUint64.c b/libparc/parc/concurrent/parc_AtomicUint64.c
index 326f39db..326f39db 100755..100644
--- a/libparc/parc/concurrent/parc_AtomicUint64.c
+++ b/libparc/parc/concurrent/parc_AtomicUint64.c
diff --git a/libparc/parc/concurrent/parc_AtomicUint64.h b/libparc/parc/concurrent/parc_AtomicUint64.h
index a6ac3ec1..a6ac3ec1 100755..100644
--- a/libparc/parc/concurrent/parc_AtomicUint64.h
+++ b/libparc/parc/concurrent/parc_AtomicUint64.h
diff --git a/libparc/parc/concurrent/parc_AtomicUint8.c b/libparc/parc/concurrent/parc_AtomicUint8.c
index fd34258b..fd34258b 100755..100644
--- a/libparc/parc/concurrent/parc_AtomicUint8.c
+++ b/libparc/parc/concurrent/parc_AtomicUint8.c
diff --git a/libparc/parc/concurrent/parc_AtomicUint8.h b/libparc/parc/concurrent/parc_AtomicUint8.h
index 7434b93d..7434b93d 100755..100644
--- a/libparc/parc/concurrent/parc_AtomicUint8.h
+++ b/libparc/parc/concurrent/parc_AtomicUint8.h
diff --git a/libparc/parc/concurrent/parc_FutureTask.c b/libparc/parc/concurrent/parc_FutureTask.c
index d323e0bd..d323e0bd 100755..100644
--- a/libparc/parc/concurrent/parc_FutureTask.c
+++ b/libparc/parc/concurrent/parc_FutureTask.c
diff --git a/libparc/parc/concurrent/parc_FutureTask.h b/libparc/parc/concurrent/parc_FutureTask.h
index 9a5776c5..9a5776c5 100755..100644
--- a/libparc/parc/concurrent/parc_FutureTask.h
+++ b/libparc/parc/concurrent/parc_FutureTask.h
diff --git a/libparc/parc/concurrent/parc_Lock.c b/libparc/parc/concurrent/parc_Lock.c
index 493fd44f..493fd44f 100755..100644
--- a/libparc/parc/concurrent/parc_Lock.c
+++ b/libparc/parc/concurrent/parc_Lock.c
diff --git a/libparc/parc/concurrent/parc_Lock.h b/libparc/parc/concurrent/parc_Lock.h
index ecba1c19..ecba1c19 100755..100644
--- a/libparc/parc/concurrent/parc_Lock.h
+++ b/libparc/parc/concurrent/parc_Lock.h
diff --git a/libparc/parc/concurrent/parc_Notifier.c b/libparc/parc/concurrent/parc_Notifier.c
index 67e8cfb3..e313cd6e 100755..100644
--- a/libparc/parc/concurrent/parc_Notifier.c
+++ b/libparc/parc/concurrent/parc_Notifier.c
@@ -13,26 +13,29 @@
* limitations under the License.
*/
-/**
- */
+#ifndef _WIN32
+#include <unistd.h>
+#endif
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
-
#include <parc/assert/parc_Assert.h>
-
#include <parc/concurrent/parc_Notifier.h>
#include <parc/algol/parc_Object.h>
-#ifdef __GNUC__
+#if defined(__GNUC__)
#define ATOMIC_ADD_AND_FETCH(ptr, increment) __sync_add_and_fetch(ptr, increment)
#define ATOMIC_BOOL_CAS(ptr, oldvalue, newvalue) __sync_bool_compare_and_swap(ptr, oldvalue, newvalue)
#define ATOMIC_FETCH(ptr) ATOMIC_ADD_AND_FETCH(ptr, 0)
#define ATOMIC_SET(ptr, oldvalue, newvalue) ATOMIC_BOOL_CAS(ptr, oldvalue, newvalue)
+#elif defined(_WIN32)
+#define ATOMIC_ADD_AND_FETCH(ptr, increment) (++(*(ptr)))
+#define ATOMIC_BOOL_CAS(ptr, oldvalue, newvalue) (InterlockedCompareExchangePointer((volatile PVOID *)ptr, (PVOID)newvalue, (PVOID)oldvalue) == ptr)
+#define ATOMIC_FETCH(ptr) ATOMIC_ADD_AND_FETCH(ptr, 0)
+#define ATOMIC_SET(ptr, oldvalue, newvalue) ATOMIC_BOOL_CAS(ptr, oldvalue, newvalue)
#else
#error "Only GNUC supported, we need atomic operations"
#endif
@@ -63,6 +66,8 @@ parcObject_ExtendPARCObject(PARCNotifier, _parcNotifier_Finalize, NULL, NULL, NU
static bool
_parcNotifier_MakeNonblocking(PARCNotifier *notifier)
{
+
+#ifndef _WIN32
// set the read side to be non-blocking
int flags = fcntl(notifier->fds[PARCNotifierReadFd], F_GETFL, 0);
if (flags == 0) {
@@ -71,6 +76,8 @@ _parcNotifier_MakeNonblocking(PARCNotifier *notifier)
}
}
perror("fcntl error");
+#endif
+
return false;
}
@@ -82,12 +89,15 @@ parcNotifier_Create(void)
notifier->paused = false;
notifier->skippedNotify = false;
+#ifndef _WIN32
int failure = pipe(notifier->fds);
parcAssertFalse(failure, "Error on pipe: %s", strerror(errno));
if (!_parcNotifier_MakeNonblocking(notifier)) {
- parcObject_Release((void **) &notifier);
+ parcObject_Release((void **)&notifier);
}
+#endif
+
}
return notifier;
@@ -146,4 +156,4 @@ parcNotifier_StartEvents(PARCNotifier *notifier)
// we missed some notifications, so re-signal ourself
parcNotifier_Notify(notifier);
}
-}
+} \ No newline at end of file
diff --git a/libparc/parc/concurrent/parc_Notifier.h b/libparc/parc/concurrent/parc_Notifier.h
index 44eda3b5..e139c141 100755..100644
--- a/libparc/parc/concurrent/parc_Notifier.h
+++ b/libparc/parc/concurrent/parc_Notifier.h
@@ -175,4 +175,5 @@ void parcNotifier_PauseEvents(PARCNotifier *notifier);
* @endcode
*/
void parcNotifier_StartEvents(PARCNotifier *notifier);
+
#endif // libparc_parc_Notifier_h
diff --git a/libparc/parc/concurrent/parc_RingBuffer.c b/libparc/parc/concurrent/parc_RingBuffer.c
index d5fb677b..d5fb677b 100755..100644
--- a/libparc/parc/concurrent/parc_RingBuffer.c
+++ b/libparc/parc/concurrent/parc_RingBuffer.c
diff --git a/libparc/parc/concurrent/parc_RingBuffer.h b/libparc/parc/concurrent/parc_RingBuffer.h
index 211f044e..211f044e 100755..100644
--- a/libparc/parc/concurrent/parc_RingBuffer.h
+++ b/libparc/parc/concurrent/parc_RingBuffer.h
diff --git a/libparc/parc/concurrent/parc_RingBuffer_1x1.c b/libparc/parc/concurrent/parc_RingBuffer_1x1.c
index a93049eb..9827154b 100755..100644
--- a/libparc/parc/concurrent/parc_RingBuffer_1x1.c
+++ b/libparc/parc/concurrent/parc_RingBuffer_1x1.c
@@ -71,22 +71,23 @@
*
*/
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <errno.h>
#include <string.h>
-#include <unistd.h>
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_Object.h>
#include <parc/assert/parc_Assert.h>
-
#include <parc/concurrent/parc_RingBuffer_1x1.h>
-#ifdef __GNUC__
-
+#if defined(__GNUC__)
// on x86 or x86_64, simple assignment will work
#if (__x86_64__ || __i386__)
#define ATOMIC_ADD_AND_FETCH(ptr, increment) __sync_add_and_fetch(ptr, increment)
@@ -100,6 +101,10 @@
#define ATOMIC_SET(ptr, oldvalue, newvalue) ATOMIC_BOOL_CAS(ptr, oldvalue, newvalue)
#endif
+#elif defined(_WIN32)
+#define ATOMIC_FETCH(ptr) *(ptr)
+#define ATOMIC_SET(ptr, oldvalue, newvalue) *(ptr) = newvalue
+#define ATOMIC_BOOL_CAS(ptr, oldvalue, newvalue) (InterlockedCompareExchangePointer(ptr,newvalue,oldvalue) == ptr)
#else
#error "Only GNUC supported, we need atomic operations"
#endif
diff --git a/libparc/parc/concurrent/parc_RingBuffer_1x1.h b/libparc/parc/concurrent/parc_RingBuffer_1x1.h
index 4fd48e6b..4fd48e6b 100755..100644
--- a/libparc/parc/concurrent/parc_RingBuffer_1x1.h
+++ b/libparc/parc/concurrent/parc_RingBuffer_1x1.h
diff --git a/libparc/parc/concurrent/parc_RingBuffer_NxM.c b/libparc/parc/concurrent/parc_RingBuffer_NxM.c
index 4ea69e58..4ea69e58 100755..100644
--- a/libparc/parc/concurrent/parc_RingBuffer_NxM.c
+++ b/libparc/parc/concurrent/parc_RingBuffer_NxM.c
diff --git a/libparc/parc/concurrent/parc_RingBuffer_NxM.h b/libparc/parc/concurrent/parc_RingBuffer_NxM.h
index 8cf38fdc..8cf38fdc 100755..100644
--- a/libparc/parc/concurrent/parc_RingBuffer_NxM.h
+++ b/libparc/parc/concurrent/parc_RingBuffer_NxM.h
diff --git a/libparc/parc/concurrent/parc_ScheduledTask.c b/libparc/parc/concurrent/parc_ScheduledTask.c
index 4875abf7..e9636d28 100755..100644
--- a/libparc/parc/concurrent/parc_ScheduledTask.c
+++ b/libparc/parc/concurrent/parc_ScheduledTask.c
@@ -13,17 +13,16 @@
* limitations under the License.
*/
+#ifndef _WIN32
+#include <sys/time.h>
+#endif
-/**
- */
#include <config.h>
-#include <sys/time.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_DisplayIndented.h>
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_Time.h>
-
#include <parc/concurrent/parc_ScheduledTask.h>
#include <parc/concurrent/parc_FutureTask.h>
diff --git a/libparc/parc/concurrent/parc_ScheduledTask.h b/libparc/parc/concurrent/parc_ScheduledTask.h
index e56fb5f5..e56fb5f5 100755..100644
--- a/libparc/parc/concurrent/parc_ScheduledTask.h
+++ b/libparc/parc/concurrent/parc_ScheduledTask.h
diff --git a/libparc/parc/concurrent/parc_ScheduledThreadPool.c b/libparc/parc/concurrent/parc_ScheduledThreadPool.c
index 0b77372e..6e544a92 100644
--- a/libparc/parc/concurrent/parc_ScheduledThreadPool.c
+++ b/libparc/parc/concurrent/parc_ScheduledThreadPool.c
@@ -57,7 +57,7 @@ _workerThread(PARCThread *thread, PARCScheduledThreadPool *pool)
parcSortedList_Notify(pool->workQueue);
} else {
- parcSortedList_WaitFor(pool->workQueue, executionDelay);
+ parcSortedList_WaitFor(pool->workQueue, (const unsigned long)executionDelay);
}
} else {
parcSortedList_Wait(pool->workQueue);
diff --git a/libparc/parc/concurrent/parc_ScheduledThreadPool.h b/libparc/parc/concurrent/parc_ScheduledThreadPool.h
index 36c26909..36c26909 100755..100644
--- a/libparc/parc/concurrent/parc_ScheduledThreadPool.h
+++ b/libparc/parc/concurrent/parc_ScheduledThreadPool.h
diff --git a/libparc/parc/concurrent/parc_Synchronizer.c b/libparc/parc/concurrent/parc_Synchronizer.c
index ab331442..ab331442 100755..100644
--- a/libparc/parc/concurrent/parc_Synchronizer.c
+++ b/libparc/parc/concurrent/parc_Synchronizer.c
diff --git a/libparc/parc/concurrent/parc_Synchronizer.h b/libparc/parc/concurrent/parc_Synchronizer.h
index a387888f..a387888f 100755..100644
--- a/libparc/parc/concurrent/parc_Synchronizer.h
+++ b/libparc/parc/concurrent/parc_Synchronizer.h
diff --git a/libparc/parc/concurrent/parc_Thread.c b/libparc/parc/concurrent/parc_Thread.c
index 50be042d..8004f672 100644
--- a/libparc/parc/concurrent/parc_Thread.c
+++ b/libparc/parc/concurrent/parc_Thread.c
@@ -210,7 +210,11 @@ parcThread_Cancel(PARCThread *thread)
int
parcThread_GetId(const PARCThread *thread)
{
- return (int) thread->thread;
+#ifndef _WIN32
+ return (int)thread->thread;
+#else
+ return pthread_getw32threadid_np(thread->thread);
+#endif
}
bool
diff --git a/libparc/parc/concurrent/parc_Thread.h b/libparc/parc/concurrent/parc_Thread.h
index f24306ae..f24306ae 100755..100644
--- a/libparc/parc/concurrent/parc_Thread.h
+++ b/libparc/parc/concurrent/parc_Thread.h
diff --git a/libparc/parc/concurrent/parc_ThreadPool.c b/libparc/parc/concurrent/parc_ThreadPool.c
index 2d9ef6d6..67c4bcff 100644
--- a/libparc/parc/concurrent/parc_ThreadPool.c
+++ b/libparc/parc/concurrent/parc_ThreadPool.c
@@ -276,7 +276,7 @@ parcThreadPool_AwaitTermination(PARCThreadPool *pool, PARCTimeout *timeout)
} else {
// This is not accurate as this will continue the delay, rather than keep a cumulative amount of delay.
uint64_t delay = parcTimeout_InNanoSeconds(timeout);
- parcLinkedList_WaitFor(pool->workQueue, delay);
+ parcLinkedList_WaitFor(pool->workQueue, (const unsigned long)delay);
}
}
result = true;
diff --git a/libparc/parc/concurrent/parc_ThreadPool.h b/libparc/parc/concurrent/parc_ThreadPool.h
index 7a7b548e..7a7b548e 100755..100644
--- a/libparc/parc/concurrent/parc_ThreadPool.h
+++ b/libparc/parc/concurrent/parc_ThreadPool.h
diff --git a/libparc/parc/concurrent/parc_Timeout.c b/libparc/parc/concurrent/parc_Timeout.c
index 4ea03977..4ea03977 100755..100644
--- a/libparc/parc/concurrent/parc_Timeout.c
+++ b/libparc/parc/concurrent/parc_Timeout.c
diff --git a/libparc/parc/concurrent/parc_Timer.c b/libparc/parc/concurrent/parc_Timer.c
index b1ecb5d2..b1ecb5d2 100755..100644
--- a/libparc/parc/concurrent/parc_Timer.c
+++ b/libparc/parc/concurrent/parc_Timer.c
diff --git a/libparc/parc/concurrent/parc_Timer.h b/libparc/parc/concurrent/parc_Timer.h
index 416bfba4..416bfba4 100755..100644
--- a/libparc/parc/concurrent/parc_Timer.h
+++ b/libparc/parc/concurrent/parc_Timer.h
diff --git a/libparc/parc/concurrent/test/test_parc_Notifier.c b/libparc/parc/concurrent/test/test_parc_Notifier.c
index 97ce6615..97ce6615 100755..100644
--- a/libparc/parc/concurrent/test/test_parc_Notifier.c
+++ b/libparc/parc/concurrent/test/test_parc_Notifier.c
diff --git a/libparc/parc/concurrent/test/test_parc_RingBuffer_1x1.c b/libparc/parc/concurrent/test/test_parc_RingBuffer_1x1.c
index a977dfbc..a977dfbc 100755..100644
--- a/libparc/parc/concurrent/test/test_parc_RingBuffer_1x1.c
+++ b/libparc/parc/concurrent/test/test_parc_RingBuffer_1x1.c
diff --git a/libparc/parc/concurrent/test/test_parc_RingBuffer_NxM.c b/libparc/parc/concurrent/test/test_parc_RingBuffer_NxM.c
index 974da053..974da053 100755..100644
--- a/libparc/parc/concurrent/test/test_parc_RingBuffer_NxM.c
+++ b/libparc/parc/concurrent/test/test_parc_RingBuffer_NxM.c
diff --git a/libparc/parc/concurrent/test/test_parc_Synchronizer.c b/libparc/parc/concurrent/test/test_parc_Synchronizer.c
index 34d9c711..34d9c711 100755..100644
--- a/libparc/parc/concurrent/test/test_parc_Synchronizer.c
+++ b/libparc/parc/concurrent/test/test_parc_Synchronizer.c