renamed apple.h to endian.h because it turns out that it is also used for linux systems, and removed double implemented ChannelImpl::get() function
This commit is contained in:
parent
3e47191f90
commit
328820f898
|
|
@ -26,13 +26,11 @@
|
|||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
// include compatibilities for apple
|
||||
#include <amqpcpp/apple.h>
|
||||
|
||||
// forward declarations
|
||||
#include <amqpcpp/classes.h>
|
||||
|
||||
// utility classes
|
||||
#include <amqpcpp/endian.h>
|
||||
#include <amqpcpp/buffer.h>
|
||||
#include <amqpcpp/bytebuffer.h>
|
||||
#include <amqpcpp/receivedframe.h>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ callbacks.h
|
|||
channel.h
|
||||
channelimpl.h
|
||||
classes.h
|
||||
compat_endian.h
|
||||
endian.h
|
||||
connection.h
|
||||
connectionhandler.h
|
||||
connectionimpl.h
|
||||
|
|
|
|||
|
|
@ -1,31 +1,50 @@
|
|||
#ifndef __AMQP_CPP_COMPAT_ENDIAN_H__
|
||||
#define __AMQP_CPP_COMPAT_ENDIAN_H__
|
||||
/**
|
||||
* Endian.h
|
||||
*
|
||||
* On Apple systems, there are no macro's to convert between little
|
||||
* and big endian byte orders. This header file adds the missing macros
|
||||
*
|
||||
* @author madmongo1 <https://github.com/madmongo1>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Include guard
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* The contents of the file are only relevant for Apple
|
||||
*/
|
||||
#if defined(__APPLE__)
|
||||
|
||||
// dependencies
|
||||
#include <machine/endian.h>
|
||||
|
||||
#include <libkern/OSByteOrder.h>
|
||||
|
||||
// define 16 bit macros
|
||||
#define htobe16(x) OSSwapHostToBigInt16(x)
|
||||
#define htole16(x) OSSwapHostToLittleInt16(x)
|
||||
#define be16toh(x) OSSwapBigToHostInt16(x)
|
||||
#define le16toh(x) OSSwapLittleToHostInt16(x)
|
||||
|
||||
// define 32 bit macros
|
||||
#define htobe32(x) OSSwapHostToBigInt32(x)
|
||||
#define htole32(x) OSSwapHostToLittleInt32(x)
|
||||
#define be32toh(x) OSSwapBigToHostInt32(x)
|
||||
#define le32toh(x) OSSwapLittleToHostInt32(x)
|
||||
|
||||
// define 64 but macros
|
||||
#define htobe64(x) OSSwapHostToBigInt64(x)
|
||||
#define htole64(x) OSSwapHostToLittleInt64(x)
|
||||
#define be64toh(x) OSSwapBigToHostInt64(x)
|
||||
#define le64toh(x) OSSwapLittleToHostInt64(x)
|
||||
|
||||
// not on apple
|
||||
#else
|
||||
|
||||
// non-apple systems have their own endian header file
|
||||
#include <endian.h>
|
||||
|
||||
// end of "#if defined(__APPLE__)"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -589,53 +589,6 @@ DeferredGet &ChannelImpl::get(const std::string &queue, int flags)
|
|||
return *deferred;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single message from RabbitMQ
|
||||
*
|
||||
* When you call this method, you can get one single message from the queue (or none
|
||||
* at all if the queue is empty). The deferred object that is returned, should be used
|
||||
* to install a onEmpty() and onSuccess() callback function that will be called
|
||||
* when the message is consumed and/or when the message could not be consumed.
|
||||
*
|
||||
* The following flags are supported:
|
||||
*
|
||||
* - noack if set, consumed messages do not have to be acked, this happens automatically
|
||||
*
|
||||
* @param queue name of the queue to consume from
|
||||
* @param flags optional flags
|
||||
*
|
||||
* The object returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onEmpty(), onError() and onFinalize() methods.
|
||||
*
|
||||
* The onSuccess() callback has the following signature:
|
||||
*
|
||||
* void myCallback(const Message &message, uint64_t deliveryTag, bool redelivered);
|
||||
*
|
||||
* For example: channel.get("myqueue").onSuccess([](const Message &message, uint64_t deliveryTag, bool redelivered) {
|
||||
*
|
||||
* std::cout << "Message fetched" << std::endl;
|
||||
*
|
||||
* }).onEmpty([]() {
|
||||
*
|
||||
* std::cout << "Queue is empty" << std::endl;
|
||||
*
|
||||
* });
|
||||
*/
|
||||
DeferredGet &ChannelImpl::get(const std::string &queue, int flags)
|
||||
{
|
||||
// the get frame to send
|
||||
BasicGetFrame frame(_id, queue, flags & noack);
|
||||
|
||||
// send the frame, and create deferred object
|
||||
auto *deferred = new DeferredGet(this, send(frame));
|
||||
|
||||
// push to list
|
||||
push(deferred);
|
||||
|
||||
// done
|
||||
return *deferred;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledge a message
|
||||
* @param deliveryTag the delivery tag
|
||||
|
|
|
|||
Loading…
Reference in New Issue