Tizen Native API
9.0
|
The tizen core channel API provides functions to send messages between threads.
Required Header
#include <tizen_core.h>
Overview
The tizen core channel can send messages securely between threads without risk of corruption or loss. It provides functions to create channel sender/receiver pair and communication APIs.
Functions | |
int | tizen_core_channel_make_pair (tizen_core_channel_sender_h *sender, tizen_core_channel_receiver_h *receiver) |
Makes a pair of channel sender and receiver. | |
int | tizen_core_channel_sender_send (tizen_core_channel_sender_h sender, tizen_core_channel_object_h object) |
Sends the channel object to the receiver. | |
int | tizen_core_channel_sender_destroy (tizen_core_channel_sender_h sender) |
Destroys the channel sender handle. | |
int | tizen_core_channel_sender_clone (tizen_core_channel_sender_h sender, tizen_core_channel_sender_h *cloned_sender) |
Creates and returns a copy of the given the sender handle. | |
int | tizen_core_channel_receiver_receive (tizen_core_channel_receiver_h receiver, tizen_core_channel_object_h *object) |
Receives the channel object from the sender. | |
int | tizen_core_channel_receiver_destroy (tizen_core_channel_receiver_h receiver) |
Destroys the tizen core channel receiver handle. | |
int | tizen_core_channel_object_create (tizen_core_channel_object_h *object) |
Creates the tizen core channel object handle. | |
int | tizen_core_channel_object_destroy (tizen_core_channel_object_h object) |
Destroys the tizen core channel object handle. | |
int | tizen_core_channel_object_set_id (tizen_core_channel_object_h object, int id) |
Sets the ID to the tizen core channel object handle. | |
int | tizen_core_channel_object_get_id (tizen_core_channel_object_h object, int *id) |
Gets the ID from the tizen core channel object handle. | |
int | tizen_core_channel_object_set_data (tizen_core_channel_object_h object, void *data) |
Sets the data to the tizen core channel object handle. | |
int | tizen_core_channel_object_get_data (tizen_core_channel_object_h object, void **data) |
Gets the data from the tizen core channel object handle. | |
int | tizen_core_channel_object_get_sender_task_name (tizen_core_channel_object_h object, const char **task_name) |
Gets the sender task name from the tizen core channel object handle. | |
Typedefs | |
typedef void * | tizen_core_channel_sender_h |
The tizen core channel sender handle. | |
typedef void * | tizen_core_channel_receiver_h |
The tizen core channel receiver handle. | |
typedef void * | tizen_core_channel_object_h |
The tizen core channel object handle. |
Typedef Documentation
typedef void* tizen_core_channel_object_h |
The tizen core channel object handle.
- Since :
- 9.0
typedef void* tizen_core_channel_receiver_h |
The tizen core channel receiver handle.
- Since :
- 9.0
typedef void* tizen_core_channel_sender_h |
The tizen core channel sender handle.
- Since :
- 9.0
Function Documentation
int tizen_core_channel_make_pair | ( | tizen_core_channel_sender_h * | sender, |
tizen_core_channel_receiver_h * | receiver | ||
) |
Makes a pair of channel sender and receiver.
- Since :
- 9.0
- Remarks:
- The sender should be released using tizen_core_channel_sender_destroy().
- The receiver should be released using tizen_core_channel_receiver_destroy().
- Parameters:
-
[out] sender The tizen core channel sender handle [out] receiver The tizen core channel receiver handle
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
TIZEN_CORE_ERROR_NONE Successful TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory TIZEN_CORE_ERROR_INVALID_CONTEXT Invalid context
#include <tizen_core.h> { tizen_core_channel_sender_h sender = NULL; tizen_core_channel_receiver_h receiver = NULL; int ret; ret = tizen_core_channel_make_pair(&sender, &receiver); if (ret != TIZEN_CORE_ERROR_NONE) { dlog_print(DLOG_ERROR, LOG_TAG, "Failed to make channel pair"); return; } }
int tizen_core_channel_object_create | ( | tizen_core_channel_object_h * | object | ) |
Creates the tizen core channel object handle.
- Since :
- 9.0
- Remarks:
- The object should be released using tizen_core_channel_object_destroy().
- Parameters:
-
[out] object The tizen core channel object handle
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
TIZEN_CORE_ERROR_NONE Successful TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory TIZEN_CORE_ERROR_INVALID_CONTEXT Invalid context
#include <tizen_core.h> { tizen_core_channel_object_h object = NULL; int ret; ret = tizen_core_channel_object_create(&object); if (ret != TIZEN_CORE_ERROR_NONE) { dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create channel object"); return; } tizen_core_channel_object_destroy(object); }
- See also:
- tizen_core_channel_object_destroy()
int tizen_core_channel_object_destroy | ( | tizen_core_channel_object_h | object | ) |
Destroys the tizen core channel object handle.
- Since :
- 9.0
- Parameters:
-
[in] object The tizen core channel object handle
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
TIZEN_CORE_ERROR_NONE Successful TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
#include <tizen_core.h> { tizen_core_channel_object_h object = NULL; int ret; tizen_core_channel_object_create(&object); ret = tizen_core_channel_object_destroy(object); if (ret != TIZEN_CORE_ERROR_NONE) dlog_print(DLOG_ERROR, LOG_TAG, "Failed to destroy channel object"); }
- See also:
- tizen_core_channel_object_create()
int tizen_core_channel_object_get_data | ( | tizen_core_channel_object_h | object, |
void ** | data | ||
) |
Gets the data from the tizen core channel object handle.
- Since :
- 9.0
- Remarks:
- The data should be released using release function.
- Parameters:
-
[in] object The tizen core channel object handle [out] data The channel data
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
TIZEN_CORE_ERROR_NONE Successful TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
#include <tizen_core.h> { tizen_core_channel_object_h object = NULL; char *data = NULL; int ret; tizen_core_channel_object_create(&object); tizen_core_channel_object_set_data(object, strdup("22")); ret = tizen_core_channel_object_get_data(object, &data); if (ret != TIZEN_CORE_ERROR_NONE) { dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get channel data"); tizen_core_channel_object_destroy(object); return; } dlog_print(DLOG_INFO, LOG_TAG, "data=%s", data); free(data); tizen_core_channel_object_destroy(object); }
- See also:
- tizen_core_channel_object_set_data()
int tizen_core_channel_object_get_id | ( | tizen_core_channel_object_h | object, |
int * | id | ||
) |
Gets the ID from the tizen core channel object handle.
- Since :
- 9.0
- Parameters:
-
[in] object The tizen core channel object handle [out] id The channel ID
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
TIZEN_CORE_ERROR_NONE Successful TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
#include <tizen_core.h> { tizen_core_channel_object_h object = NULL; int id = 0; int ret; tizen_core_channel_object_create(&object); tizen_core_channel_object_set_id(object, 22); ret = tizen_core_channel_object_get_id(object, &id); if (ret != TIZEN_CORE_ERROR_NONE) { dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get channel type"); return; } tizen_core_channel_object_destroy(object); }
- See also:
- tizen_core_channel_object_set_id()
int tizen_core_channel_object_get_sender_task_name | ( | tizen_core_channel_object_h | object, |
const char ** | task_name | ||
) |
Gets the sender task name from the tizen core channel object handle.
- Since :
- 9.0
- Remarks:
- The task_name must not be deallocated by the application.
- Parameters:
-
[in] object The tizen core channel object handle [out] task_name The sender task name
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
TIZEN_CORE_ERROR_NONE Successful TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter TIZEN_CORE_ERROR_INVALID_CONTEXT Invalid context
#include <tizen_core.h> static void print_task_name(tizen_core_channel_object_h object) { const char *task_name = NULL; int ret; ret = tizen_core_channel_object_get_sender_task_name(object, &task_name); if (ret != TIZEN_CORE_ERROR_NONE) { dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get sender task name"); return; } dlog_print(DLOG_INFO, LOG_TAG, "sender task=%s", task_name"); }
int tizen_core_channel_object_set_data | ( | tizen_core_channel_object_h | object, |
void * | data | ||
) |
Sets the data to the tizen core channel object handle.
- Since :
- 9.0
- Remarks:
- The data should be released using release function if the data is created by the memory allocation.
- Parameters:
-
[in] object The tizen core channel object handle [in] data The channel data
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
TIZEN_CORE_ERROR_NONE Successful TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
#include <tizen_core.h> { tizen_core_channel_object_h object = NULL; char *data = NULL; int ret; tizen_core_channel_object_create(&object); ret = tizen_core_channel_object_set_data(object, strdup("22")); if (ret != TIZEN_CORE_ERROR_NONE) { dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set channel data"); tizen_core_channel_object_destroy(object); return; } tizen_core_channel_object_get_data(object, &data); free(data); tizen_core_channel_object_destroy(object); }
- See also:
- tizen_core_channel_object_get_data()
int tizen_core_channel_object_set_id | ( | tizen_core_channel_object_h | object, |
int | id | ||
) |
Sets the ID to the tizen core channel object handle.
- Since :
- 9.0
- Parameters:
-
[in] object The tizen core channel object handle [in] id The channel ID
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
TIZEN_CORE_ERROR_NONE Successful TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
#include <tizen_core.h> { tizen_core_channel_object_h object = NULL; int ret; tizen_core_channel_object_create(&object); ret = tizen_core_channel_object_set_id(object, 22); if (ret != TIZEN_CORE_ERROR_NONE) { dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set channel type"); tizen_core_channel_object_destroy(object); return; } tizen_core_channel_object_destroy(object); }
- See also:
- tizen_core_channel_object_get_type()
int tizen_core_channel_receiver_destroy | ( | tizen_core_channel_receiver_h | receiver | ) |
Destroys the tizen core channel receiver handle.
- Since :
- 9.0
- Parameters:
-
[in] receiver The tizen core channel receiver handle
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
TIZEN_CORE_ERROR_NONE Successful TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
#include <tizen_core.h> { tizen_core_channel_sender_h sender = NULL; tizen_core_channel_receiver_h receiver = NULL; int ret; tizen_core_channel_make_pair(&sender, &receiver); tizen_core_channel_sender_destroy(sender); ret = tizen_core_channel_receiver_destroy(receiver); if (ret != TIZEN_CORE_ERROR_NONE) dlog_print(DLOG_ERROR, LOG_TAG, "Failed to destroy channel receiver"); }
- See also:
- tizen_core_channel_make_pair()
int tizen_core_channel_receiver_receive | ( | tizen_core_channel_receiver_h | receiver, |
tizen_core_channel_object_h * | object | ||
) |
Receives the channel object from the sender.
- Since :
- 9.0
- Remarks:
- The object should be released using tizen_core_channel_object_destroy().
- Parameters:
-
[in] receiver The tizen core channel receiver handle [out] object The tizen core channel object handle
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
TIZEN_CORE_ERROR_NONE Successful TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
#include <tizen_core.h> { tizen_core_channel_sender_h sender = NULL; tizen_core_channel_receiver_h receiver = NULL; tizen_core_channel_object_h object = NULL; int id = -1; char *data = NULL; int ret; tizen_core_channel_make_pair(&sender, &receiver); tizen_core_channel_object_create(&object); tizen_core_channel_object_set_id(object, 22); tizen_core_channel_object_set_data(object, strdup("22")); tizen_core_channel_sender_send(sender, object); tizen_core_channel_object_destroy(object); object = NULL; ret = tizen_core_channel_receiver_receive(receiver, &object); if (ret == TIZEN_CORE_ERROR_NONE) { tizen_core_channel_object_get_id(object, &id); tizen_core_channel_object_get_data(object, &data); dlog_print(DLOG_INFO, LOG_TAG, "id=%d, data=%s", id, data); free(data); tizen_core_channel_object_destroy(object); } tizen_core_channel_sender_destroy(sender); tizen_core_channel_receiver_destroy(receiver); }
- See also:
- tizen_core_channel_object_destroy()
int tizen_core_channel_sender_clone | ( | tizen_core_channel_sender_h | sender, |
tizen_core_channel_sender_h * | cloned_sender | ||
) |
Creates and returns a copy of the given the sender handle.
- Since :
- 9.0
- Remarks:
- The cloned_sender should be released using tizen_core_channel_sender_destroy().
- Parameters:
-
[in] sender The tizen core channel sender handle [out] cloned_sender If successful, a newly created tizen core channel sender handle will be returned
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
TIZEN_CORE_ERROR_NONE Successful TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter TIZEN_CORE_ERROR_OUT_OF_MEMORY Out of memory
#include <tizen_core.h> { tizen_core_channel_sender_h sender = NULL; tizen_core_channel_sender_h cloned_sender = NULL; tizen_core_channel_receiver_h receiver = NULL; int ret; tizen_core_channel_make_pair(&sender, &receiver); ret = tizen_core_channel_sender_clone(sender, &cloned_sender); if (ret != TIZEN_CORE_ERROR_NONE) dlog_print(DLOG_ERROR, LOG_TAG, "Failed to clone channel sender"); }
- See also:
- tizen_core_channel_sender_destroy()
int tizen_core_channel_sender_destroy | ( | tizen_core_channel_sender_h | sender | ) |
Destroys the channel sender handle.
- Since :
- 9.0
- Parameters:
-
[in] sender The tizen core channel sender handle
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
TIZEN_CORE_ERROR_NONE Successful TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
#include <tizen_core.h> { tizen_core_channel_sender_h sender = NULL; tizen_core_channel_receiver_h receiver = NULL; int ret; tizen_core_channel_make_pair(&sender, &receiver); tizen_core_channel_receiver_destroy(receiver); ret = tizen_core_channel_sender_destroy(sender); if (ret != TIZEN_CORE_ERROR_NONE) dlog_print(DLOG_ERROR, LOG_TAG, "Failed to destroy channel sender"); }
int tizen_core_channel_sender_send | ( | tizen_core_channel_sender_h | sender, |
tizen_core_channel_object_h | object | ||
) |
Sends the channel object to the receiver.
- Since :
- 9.0
- Parameters:
-
[in] sender The tizen core channel sender handle [in] object The tizen core channel object handle
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
TIZEN_CORE_ERROR_NONE Successful TIZEN_CORE_ERROR_INVALID_PARAMETER Invalid parameter
#include <tizen_core.h> { tizen_core_channel_sender_h sender = NULL; tizen_core_channel_receiver_h receiver = NULL; tizen_core_channel_object_h object = NULL; int ret; tizen_core_channel_make_pair(&sender, &receiver); tizen_core_channel_object_create(&object); tizen_core_channel_object_set_id(object, 22); tizen_core_channel_object_set_data(object, strdup("22")); int ret = tizen_core_channel_sender_send(sender, object); if (ret != TIZEN_CORE_ERROR_NONE) dlog_print(DLOG_ERROR, LOG_TAG, "Failed to send object"); tizen_core_channel_object_destroy(object); }
- See also:
- tizen_core_channel_object_create()