version 1.32.4.1, 2002/10/25 20:49:43
|
version 1.36, 2003/10/22 14:26:03
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2003//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development |
// The Open Group, Tivoli Systems |
// Company, L. P., IBM Corp., The Open Group, Tivoli Systems. |
|
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; |
|
// IBM Corp.; EMC Corporation, The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
typedef HashTable<Uint32, MessageQueue*, EqualFunc<Uint32>, HashFunc<Uint32> > | typedef HashTable<Uint32, MessageQueue*, EqualFunc<Uint32>, HashFunc<Uint32> > |
QueueTable; | QueueTable; |
| |
static QueueTable _queueTable(128); |
static QueueTable _queueTable(256); |
static Mutex q_table_mut ; | static Mutex q_table_mut ; |
| |
|
void MessageQueue::remove_myself(Uint32 qid) |
|
{ |
|
q_table_mut.lock(pegasus_thread_self()); |
|
|
|
_queueTable.remove(qid); |
|
q_table_mut.unlock(); |
|
} |
|
|
|
|
Uint32 MessageQueue::getNextQueueId() throw(IPCException) | Uint32 MessageQueue::getNextQueueId() throw(IPCException) |
{ | { |
static Uint32 _nextQueueId = 2; | static Uint32 _nextQueueId = 2; |
|
|
static Mutex _id_mut ; | static Mutex _id_mut ; |
_id_mut.lock(pegasus_thread_self()); | _id_mut.lock(pegasus_thread_self()); |
| |
// Assign next queue id. Handle wrap around and never assign zero as |
Uint32 queueId; |
// a queue id: |
|
| |
|
// Assign the next queue ID that is not already in use |
|
do |
|
{ |
|
// Handle wrap around and never assign zero or one as a queue id: |
if (_nextQueueId == 0) | if (_nextQueueId == 0) |
|
{ |
_nextQueueId = 2; | _nextQueueId = 2; |
|
} |
| |
Uint32 queueId = _nextQueueId++; |
queueId = _nextQueueId++; |
|
} while (lookup(queueId) != 0); |
| |
// | // |
// Unlock mutex: | // Unlock mutex: |
|
|
| |
q_table_mut.lock(pegasus_thread_self()); | q_table_mut.lock(pegasus_thread_self()); |
| |
if ( ! _queueTable.insert(_queueId, this)) |
while (!_queueTable.insert(_queueId, this)) |
abort(); |
; |
| |
q_table_mut.unlock(); | q_table_mut.unlock(); |
| |