1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#include <ndb_global.h>
17
#include "SignalQueue.hpp"
19
SignalQueue::SignalQueue() {
20
m_mutex = NdbMutex_Create();
21
m_cond = NdbCondition_Create();
22
m_signalQueueHead = NULL;
25
SignalQueue::~SignalQueue() {
28
while(m_signalQueueHead != NULL)
31
NdbMutex_Destroy(m_mutex);
33
NdbCondition_Destroy(m_cond);
41
if(m_signalQueueHead == NULL)
44
ret = m_signalQueueHead->signal;
46
QueueEntry *old = m_signalQueueHead;
47
m_signalQueueHead = m_signalQueueHead->next;
55
SignalQueue::receive(void *me, NdbApiSignal *signal) {
56
SignalQueue *q = (SignalQueue *)me;
61
SignalQueue::receive(NdbApiSignal *signal) {
62
QueueEntry *n = new QueueEntry();
68
if(m_signalQueueHead == NULL) {
69
m_signalQueueHead = n;
70
NdbCondition_Broadcast(m_cond);
74
QueueEntry *cur = m_signalQueueHead;
76
while(cur->next != NULL)
81
NdbCondition_Broadcast(m_cond);
85
SignalQueue::waitFor(int gsn, NodeId nodeid, Uint32 timeout) {
88
if(m_signalQueueHead == NULL)
89
NdbCondition_WaitTimeout(m_cond, m_mutex, timeout);
91
if(m_signalQueueHead == NULL)
95
m_signalQueueHead->signal->readSignalNumber() != gsn)
99
refToNode(m_signalQueueHead->signal->theSendersBlockRef) != nodeid)