Esempio n. 1
0
            public void ovrMessage_Init(MESSAGE id, ovrMQWait wait)
            {
                // this byref?

                this.Id   = id;
                this.Wait = wait;
                //memset( message->Parms, 0, sizeof( message->Parms ) );

                this.Parms = new ovrMessageParms[MAX_MESSAGES];

                // calloc
                // http://stackoverflow.com/questions/1622196/malloc-zeroing-out-memory
            }
            public void ovrMessage_Init(MESSAGE id, ovrMQWait wait)
            {
                // this byref?

                this.Id = id;
                this.Wait = wait;
                //memset( message->Parms, 0, sizeof( message->Parms ) );

                this.Parms = new ovrMessageParms[MAX_MESSAGES];

                // calloc
                // http://stackoverflow.com/questions/1622196/malloc-zeroing-out-memory

            }
Esempio n. 3
0
            // called by AppThreadFunction
            public bool ovrMessageQueue_GetNextMessage(out ovrMessage message, bool waitForMessages)
            {
                // 1716
                //ConsoleExtensions.tracei("enter ovrMessageQueue_GetNextMessage");

                if (this.Wait == ovrMQWait.MQ_WAIT_PROCESSED)
                {
                    pthread.pthread_cond_broadcast(ref Processed);
                    this.Wait = ovrMQWait.MQ_WAIT_NONE;
                }

                if (waitForMessages)
                {
                    ovrMessageQueue_SleepUntilMessage();
                }

                pthread.pthread_mutex_lock(ref this.Mutex);


                if (this.Tail <= this.Head)
                {
                    pthread.pthread_mutex_unlock(ref Mutex);
                    message = default(ovrMessage);
                    return(false);
                }

                message = this.Messages[Head & (MAX_MESSAGES - 1)];

                this.Head++;
                pthread.pthread_mutex_unlock(ref Mutex);

                if (message.Wait == ovrMQWait.MQ_WAIT_RECEIVED)
                {
                    // 1736!
                    //pthread.pthread_cond_broadcast(ref Processed);
                    pthread.pthread_cond_broadcast(ref Received);
                }
                else if (message.Wait == ovrMQWait.MQ_WAIT_PROCESSED)
                {
                    this.Wait = ovrMQWait.MQ_WAIT_PROCESSED;
                }

                //ConsoleExtensions.tracei("exit ovrMessageQueue_GetNextMessage");
                return(true);
            }
Esempio n. 4
0
            // appworkerThread
            // called by ovrMessageQueue_GetNextMessage
            public void ovrMessageQueue_SleepUntilMessage()
            {
                // 1699
                //ConsoleExtensions.tracei("ovrMessageQueue_SleepUntilMessage");

                if (Wait == ovrMQWait.MQ_WAIT_PROCESSED)
                {
                    pthread.pthread_cond_broadcast(ref Processed);
                    Wait = ovrMQWait.MQ_WAIT_NONE;
                }
                pthread.pthread_mutex_lock(ref Mutex);
                if (Tail > Head)
                {
                    pthread.pthread_mutex_unlock(ref Mutex);
                    return;
                }
                pthread.pthread_cond_wait(ref Posted, ref Mutex);
                pthread.pthread_mutex_unlock(ref Mutex);
            }
            // called by AppThreadFunction
            public bool ovrMessageQueue_GetNextMessage(out ovrMessage message, bool waitForMessages)
            {
                // 1716
                //ConsoleExtensions.tracei("enter ovrMessageQueue_GetNextMessage");

                if (this.Wait == ovrMQWait.MQ_WAIT_PROCESSED)
                {
                    pthread.pthread_cond_broadcast(ref Processed);
                    this.Wait = ovrMQWait.MQ_WAIT_NONE;
                }

                if (waitForMessages)
                {
                    ovrMessageQueue_SleepUntilMessage();
                }

                pthread.pthread_mutex_lock(ref this.Mutex);


                if (this.Tail <= this.Head)
                {
                    pthread.pthread_mutex_unlock(ref Mutex);
                    message = default(ovrMessage);
                    return false;
                }

                message = this.Messages[Head & (MAX_MESSAGES - 1)];

                this.Head++;
                pthread.pthread_mutex_unlock(ref Mutex);

                if (message.Wait == ovrMQWait.MQ_WAIT_RECEIVED)
                {
                    // 1736!
                    //pthread.pthread_cond_broadcast(ref Processed);
                    pthread.pthread_cond_broadcast(ref Received);
                }
                else if (message.Wait == ovrMQWait.MQ_WAIT_PROCESSED)
                {
                    this.Wait = ovrMQWait.MQ_WAIT_PROCESSED;
                }

                //ConsoleExtensions.tracei("exit ovrMessageQueue_GetNextMessage");
                return true;
            }
            // appworkerThread
            // called by ovrMessageQueue_GetNextMessage
            public void ovrMessageQueue_SleepUntilMessage()
            {
                // 1699
                //ConsoleExtensions.tracei("ovrMessageQueue_SleepUntilMessage");

                if (Wait == ovrMQWait.MQ_WAIT_PROCESSED)
                {
                    pthread.pthread_cond_broadcast(ref Processed);
                    Wait = ovrMQWait.MQ_WAIT_NONE;
                }
                pthread.pthread_mutex_lock(ref Mutex);
                if (Tail > Head)
                {
                    pthread.pthread_mutex_unlock(ref Mutex);
                    return;
                }
                pthread.pthread_cond_wait(ref Posted, ref Mutex);
                pthread.pthread_mutex_unlock(ref Mutex);
            }