Host library for controlling a WiConnect enabled Wi-Fi module.
Dependents: wiconnect-ota_example wiconnect-web_setup_example wiconnect-test-console wiconnect-tcp_server_example ... more
types/CommandQueue.h
- Committer:
- dan_ackme
- Date:
- 2014-08-11
- Revision:
- 1:6ec9998427ad
- Parent:
- 0:ea85c4bb5e1f
- Child:
- 11:ea484e1b7fc4
File content as of revision 1:6ec9998427ad:
/* * Copyright 2014, ACKme Networks * All Rights Reserved. * * This is UNPUBLISHED PROPRIETARY SOURCE CODE of ACKme Networks; * the contents of this file may not be disclosed to third parties, copied * or duplicated in any form, in whole or in part, without the prior * written permission of ACKme Networks. */ #pragma once #include "WiconnectTypes.h" namespace wiconnect { class CommandQueue { public: /*************************************************************************************************/ CommandQueue() { head = tail = queue; count = 0; } /*************************************************************************************************/ bool isFull() { return count == WICONNECT_MAX_QUEUED_COMMANDS; } /*************************************************************************************************/ bool isEmpty() { return count == 0; } /*************************************************************************************************/ bool push(QueuedCommand *cmd) { if(isFull()) { return false; } ++count; *tail = cmd; if(++tail >= queue + WICONNECT_MAX_QUEUED_COMMANDS) { tail = queue; } return true; } /*************************************************************************************************/ QueuedCommand* pop() { if(isEmpty()) return NULL; QueuedCommand* cmd = *head; --count; if(++head >= queue + WICONNECT_MAX_QUEUED_COMMANDS) { head = queue; } return cmd; } protected: QueuedCommand* queue[WICONNECT_MAX_QUEUED_COMMANDS]; QueuedCommand** head; QueuedCommand** tail; int count; }; }