/******************************************************************************* * Copyright (c) 2017 fortiss GmbH. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v20.html * * Contributors: * Florian Hoelzl - initial API and implementation *******************************************************************************/ #ifndef INC_CANOUTBOX_H_ #define INC_CANOUTBOX_H_ #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <pthread.h> #include "canthread.h" typedef struct can_outbox can_outbox_t; /** Creates an outbox with the given name. */ can_outbox_t* can_outbox_create(char* name); /** Pushes the message into outbox slots. Blocks if the slot is not empty and block flag is set. Returns true upon success. */ bool can_outbox_push_message(can_outbox_t* outbox, can_thread_message_t* message); /** Pulls the message from the outbox. Blocks if the slot is not empty and block flag is set. */ struct can_thread_message* can_outbox_pull_message(can_outbox_t* outbox); /** Clears all remaining messages in the outbox and frees their memory. */ void can_outbox_clear(can_outbox_t* outbox); /** Frees the memory used by the outbox, its slots, and any message still contained therein. */ void can_outbox_destroy(can_outbox_t* outbox); #endif /* INC_CANOUTBOX_H_ */