Tizen Native API  9.0

A new main loop model that provides improved functionality over the existing GMainLoop.

Required Header

#include <tizen_core.h>

Overview

Tizen Core is a new main loop model that provides improved functionality over the existing GMainLoop. It allows for the creation of multiple loops in different threads, enabling safe communication between them.

Functions

void tizen_core_init (void)
 Initializes the tizen core.
void tizen_core_shutdown (void)
 Shutdowns the tizen core.
bool tizen_core_ready (void)
 Checks whether the tizen core is ready or not.
int tizen_core_task_create (const char *name, bool use_thread, tizen_core_task_h *task)
 Creates the tizen core task handle.
int tizen_core_task_destroy (tizen_core_task_h task)
 Destroys the tizen core task handle.
int tizen_core_task_run (tizen_core_task_h task)
 Runs the main loop of the tizen core task.
int tizen_core_task_is_running (tizen_core_task_h task, bool *running)
 Checks whether the tizen core task is running or not.
int tizen_core_task_quit (tizen_core_task_h task)
 Exits the main loop of the tizen core task.
int tizen_core_task_get_tizen_core (tizen_core_task_h task, tizen_core_h *core)
 Gets the tizen core from the tizen core task handle.
int tizen_core_find (const char *name, tizen_core_h *core)
 Finds the tizen core from the name.
int tizen_core_find_from_this_thread (tizen_core_h *core)
 Finds the tizen core from this thread.
int tizen_core_add_idle_job (tizen_core_h core, tizen_core_task_cb callback, void *user_data, tizen_core_source_h *source)
 Adds an idle job to the tizen core.
int tizen_core_add_timer (tizen_core_h core, unsigned int interval, tizen_core_task_cb callback, void *user_data, tizen_core_source_h *source)
 Adds a timer to the tizen core.
int tizen_core_add_channel (tizen_core_h core, tizen_core_channel_receiver_h receiver, tizen_core_channel_receive_cb callback, void *user_data, tizen_core_source_h *source)
 Adds a channel receiver to the tizen core.
int tizen_core_add_event (tizen_core_h core, tizen_core_event_h event, tizen_core_source_h *source)
 Adds an event to the tizen core.
int tizen_core_emit_event (tizen_core_h core, tizen_core_event_object_h object)
 Emits the event to the tizen core.
int tizen_core_add_source (tizen_core_h core, tizen_core_source_h source)
 Adds a source to the tizen core.
int tizen_core_remove_source (tizen_core_h core, tizen_core_source_h source)
 Removes the source from the tizen core.
int tizen_core_source_create (tizen_core_source_h *source)
 Creates a tizen core source handle.
int tizen_core_source_destroy (tizen_core_source_h source)
 Destroys the tizen core source handle.
int tizen_core_source_add_poll (tizen_core_source_h source, tizen_core_poll_fd_h poll_fd)
 Waits for some events on the file descriptor.
int tizen_core_source_remove_poll (tizen_core_source_h source, tizen_core_poll_fd_h poll_fd)
 Removes to wait for some events on the file descriptor.
int tizen_core_source_set_prepare_cb (tizen_core_source_h source, tizen_core_source_prepare_cb callback, void *user_data)
 Sets the prepare callback function to the tizen core source.
int tizen_core_source_set_check_cb (tizen_core_source_h source, tizen_core_source_check_cb callback, void *user_data)
 Sets the check callback function to the tizen core source.
int tizen_core_source_set_dispatch_cb (tizen_core_source_h source, tizen_core_source_dispatch_cb callback, void *user_data)
 Sets the dispatch callback function to the tizen core source.
int tizen_core_source_set_finalize_cb (tizen_core_source_h source, tizen_core_source_finalize_cb callback, void *user_data)
 Sets the finalize callback function to the tizen core source.
int tizen_core_source_set_priority (tizen_core_source_h source, tizen_core_priority_e priority)
 Sets the priority to the tizen core source.
int tizen_core_poll_fd_create (tizen_core_poll_fd_h *poll_fd)
 Creates a tizen core poll fd handle.
int tizen_core_poll_fd_destroy (tizen_core_poll_fd_h poll_fd)
 Destroys the tizen core poll fd (file descriptor) handle.
int tizen_core_poll_fd_set_fd (tizen_core_poll_fd_h poll_fd, int fd)
 Sets the file descriptor to the poll fd handle.
int tizen_core_poll_fd_get_fd (tizen_core_poll_fd_h poll_fd, int *fd)
 Gets the file descriptor from the poll fd handle.
int tizen_core_poll_fd_set_events (tizen_core_poll_fd_h poll_fd, uint16_t events)
 Sets the requested events to the poll fd handle.
int tizen_core_poll_fd_get_events (tizen_core_poll_fd_h poll_fd, uint16_t *events)
 Gets the requested events from the poll fd handle.
int tizen_core_poll_fd_set_returned_events (tizen_core_poll_fd_h poll_fd, uint16_t returned_events)
 Sets the returned events to the poll fd handle.
int tizen_core_poll_fd_get_returned_events (tizen_core_poll_fd_h poll_fd, uint16_t *returned_events)
 Gets the returned events from the poll fd handle.

Typedefs

typedef void * tizen_core_h
 The tizen core handle.
typedef void * tizen_core_task_h
 The tizen core task handle.
typedef void * tizen_core_source_h
 The tizen core source handle.
typedef void * tizen_core_poll_fd_h
 The tizen core poll fd handle.
typedef void(* tizen_core_channel_receive_cb )(tizen_core_channel_object_h object, void *user_data)
 Called when the channel object is received.
typedef bool(* tizen_core_task_cb )(void *user_data)
 Called when the tizen core idle or timer event is emitted.
typedef bool(* tizen_core_source_prepare_cb )(tizen_core_source_h source, int *timeout, void *user_data)
 Called before all file descriptors are polled.
typedef bool(* tizen_core_source_check_cb )(tizen_core_source_h source, void *user_data)
 Called when checks whether the source is ready to be processed or not.
typedef bool(* tizen_core_source_dispatch_cb )(tizen_core_source_h source, void *user_data)
 Called when dispatches events.
typedef void(* tizen_core_source_finalize_cb )(tizen_core_source_h source, void *user_data)
 Called when the source is finalized.

Typedef Documentation

typedef void(* tizen_core_channel_receive_cb)(tizen_core_channel_object_h object, void *user_data)

Called when the channel object is received.

Since :
9.0
Remarks:
The object must not be deallocated by the application.
Parameters:
[in]objectThe tizen core channel object handle
[in]user_dataThe user data passed from the registration function
See also:
tizen_core_add_channel()
typedef void* tizen_core_h

The tizen core handle.

Since :
9.0
typedef void* tizen_core_poll_fd_h

The tizen core poll fd handle.

Since :
9.0
typedef bool(* tizen_core_source_check_cb)(tizen_core_source_h source, void *user_data)

Called when checks whether the source is ready to be processed or not.

The source is the same object for which the callback was set.

The function should return 'true' if it's ready to be dispatched.

Since :
9.0
Remarks:
The source should be released using tizen_core_source_destroy() when no longer needed.
Parameters:
[in]sourceThe tizen core source handle
[in]user_dataThe user data passed from the callback registration function
Returns:
true to indicate that the source is always ready to be processed, otherwise false to indicate that the source is not ready to be processed.
See also:
tizen_core_source_set_check_cb()
typedef bool(* tizen_core_source_dispatch_cb)(tizen_core_source_h source, void *user_data)

Called when dispatches events.

The source is the same object for which the callback was set.

Since :
9.0
Remarks:
The source should be released using tizen_core_source_destroy() when no longer needed.
Parameters:
[in]sourceThe tizen core source handle
[in]user_dataThe user data passed from the callback registration function
Returns:
true to indicate that the process is ready to dispatch the event.
See also:
tizen_core_source_set_dispatch_cb()
typedef void(* tizen_core_source_finalize_cb)(tizen_core_source_h source, void *user_data)

Called when the source is finalized.

The source is the same object for which the callback was set.

Since :
9.0
Remarks:
The source should not be released. The source is managed by the platform.
The source is managed by the platform and will be released when the callback returns.
Parameters:
[in]sourceThe tizen core source handle
[in]user_dataThe user data passed from the callback registration function
See also:
tizen_core_source_set_finalize_cb()
typedef void* tizen_core_source_h

The tizen core source handle.

Since :
9.0
typedef bool(* tizen_core_source_prepare_cb)(tizen_core_source_h source, int *timeout, void *user_data)

Called before all file descriptors are polled.

The source is the same object for which the callback was set.

The function returns a timeout value to ensure that the poll() call doesn't block too long and miss the next timeout. The timeout value is -1 to indicate that it doesn't mind how long the poll() call blocks.

Since :
9.0
Remarks:
The source should be released using tizen_core_source_destroy() when no longer needed. The timeout should not be released. The timeout can be used only in the callback.
Parameters:
[in]sourceThe tizen core source handle
[out]timeoutThe timeout
[in]user_dataThe user data passed from the callback registration function
Returns:
true to indicate that the source is always ready to be processed, otherwise false to wait until poll() has been called before it knows whether any events need to be processed.
See also:
tizen_core_source_set_prepare_cb()
typedef bool(* tizen_core_task_cb)(void *user_data)

Called when the tizen core idle or timer event is emitted.

Since :
9.0
Parameters:
[in]user_dataThe user data passed from the callback registration function
Returns:
true to repeat calling the callback function, otherwise false to remove the added source.
See also:
tizen_core_add_idle_job()
tizen_core_add_timer()
typedef void* tizen_core_task_h

The tizen core task handle.

Since :
9.0

Enumeration Type Documentation

Enumeration for the tizen core result.

Since :
9.0
Enumerator:
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

Enumeration for the event of tizen core poll fd.

Since :
9.0
See also:
tizen_core_poll_fd_set_events()
tizen_core_poll_fd_get_events()
tizen_core_poll_fd_set_returned_events()
tizen_core_poll_fd_get_returned_events()
Enumerator:
TIZEN_CORE_POLL_EVENT_IN 

There is data to read

TIZEN_CORE_POLL_EVENT_PRI 

There is some exceptional condition on the file descriptor

TIZEN_CORE_POLL_EVENT_OUT 

Writing is now possible

TIZEN_CORE_POLL_EVENT_ERR 

Error condition

TIZEN_CORE_POLL_EVENT_HUP 

Hang up

TIZEN_CORE_POLL_EVENT_NVAL 

Invalid request: fd not open

Enumeration for the priority of tizen core source.

Since :
9.0
Enumerator:
TIZEN_CORE_PRIORITY_HIGH 

High priority

TIZEN_CORE_PRIORITY_DEFAULT 

Default priority

TIZEN_CORE_PRIORITY_HIGH_IDLE 

High idle priority

TIZEN_CORE_PRIORITY_DEFAULT_IDLE 

Default idle priority

TIZEN_CORE_PRIORITY_LOW 

Low priority


Function Documentation

int tizen_core_add_channel ( tizen_core_h  core,
tizen_core_channel_receiver_h  receiver,
tizen_core_channel_receive_cb  callback,
void *  user_data,
tizen_core_source_h source 
)

Adds a channel receiver to the tizen core.

The callback function will be called when the channel event is received.

Since :
9.0
Remarks:
The source should be released using tizen_core_remove_source().
Parameters:
[in]coreThe tizen core handle
[in]receiverThe channel receiver handle
[in]callbackThe callback function to be invoked when the channel event is received
[in]user_dataThe user data to be passed to the callback function
[out]sourceThe tizen core source handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
TIZEN_CORE_ERROR_OUT_OF_MEMORYOut of memory
#include <tizen_core.h>
static void channel_receiver_cb(tizen_core_channel_object_h object, void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "channel object is received");
}

static tizen_core_source_h add_channel_event(tizen_core_channel_receiver_h receiver)
{
  tizen_core_source_h source = NULL;
  tizen_core_h core = NULL;
  int ret;

  tizen_core_find("main", &core);
  ret = tizen_core_add_channel(core, receiver, channel_receiver_cb, NULL, &source);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add channel");
    return NULL;
  }

  return source;
}
See also:
tizen_core_remove_source()

Adds an event to the tizen core.

The event handler added to the event handle is called using the corresponding core loop when the event emit occurs. When this function is called the ownership of the event is moved to the tizen core. The event will be released when the source is removed using tizen_core_remove_source().

Since :
9.0
Remarks:
The source should be released using tizen_core_remove_source().
The event MUST not be released using tizen_core_event_destroy() after adding to the tizen core using this function.
Parameters:
[in]coreThe tizen core handle
[in]eventThe tizen core event handle
[out]sourceThe tizen core source handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
TIZEN_CORE_ERROR_OUT_OF_MEMORYOut of memory
#include <tizen_core.h>
static tizen_core_source_h add_event_source(tizen_core_event_h event)
{
  tizen_core_source_h source = NULL;
  tizen_core_h core = NULL;
  int ret;

  tizen_core_find("main", &core);
  ret = tizen_core_add_event(core, event, &source);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add event");
    return NULL;
  }

  return source;
}
See also:
tizen_core_remove_source()
int tizen_core_add_idle_job ( tizen_core_h  core,
tizen_core_task_cb  callback,
void *  user_data,
tizen_core_source_h source 
)

Adds an idle job to the tizen core.

The callback function will be called whenever there are no higher priority events pending to the tizen core. The given callback function is called repeatedly until it returns false, at which point the idler source is automatically destroyed and the callback function will not be called again.

Since :
9.0
Remarks:
The source should be released using tizen_core_remove_source().
Parameters:
[in]coreThe tizen core handle
[in]callbackThe callback function to be invoked when the idle job is emitted
[in]user_dataThe user data to be passed to the callback function
[out]sourceThe tizen core source handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
TIZEN_CORE_ERROR_OUT_OF_MEMORYOut of memory
#include <tizen_core.h>
static bool idle_cb(void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "idler is invoked");
  return true;
}

static tizen_core_source_h add_idle_job(void)
{
  tizen_core_source_h source = NULL;
  tizen_core_h core = NULL;
  int ret;

  tizen_core_find("main", &core);
  ret = tizen_core_add_idle_job(core, idle_cb, NULL, &source);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add idle job");
    return NULL;
  }

  return source;
}
See also:
tizen_core_remove_source()
tizen_core_task_cb()

Adds a source to the tizen core.

Since :
9.0
Remarks:
The source should be removed using tizen_core_remove_source().
Parameters:
[in]coreThe tizen core handle
[in]sourceThe tizen core source handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
{
  tizen_core_source_h source = NULL;
  tizen_core_h core = NULL;
  int ret;

  tizen_core_source_create(&source);
  tizen_core_find("main", &core);
  ret = tizen_core_add_source(core, source);
  if (ret != TIZEN_CORE_ERROR_NONE)
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add source");
}
See also:
tizen_core_remove_source()
int tizen_core_add_timer ( tizen_core_h  core,
unsigned int  interval,
tizen_core_task_cb  callback,
void *  user_data,
tizen_core_source_h source 
)

Adds a timer to the tizen core.

The callback function will be called at regular intervals. The given callback function is called repeatedly until it returns false, at which point the timer source is automatically destroyed and the callback function will not be called again.

Since :
9.0
Remarks:
The source should be released using tizen_core_remove_source().
Parameters:
[in]coreThe tizen core handle
[in]intervalThe interval of the timer in milliseconds
[in]callbackThe callback function to be invoked when the timer is expired
[in]user_dataThe user data to be passed to the callback function
[out]sourceThe tizen core source handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
TIZEN_CORE_ERROR_OUT_OF_MEMORYOut of memory
#include <tizen_core.h>

static bool timeout_cb(void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "timeout cb is invoked");
  return true;
}

static tizen_core_source_h add_timer(unsigned int interval)
{
  tizen_core_source_h source = NULL;
  tizen_core_h core = NULL;
  int ret;

  tizen_core_find("main", &core);
  ret = tizen_core_add_timer(core, interval, timeout_cb, NULL, &source);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add timer");
    return NULL;
  }

  return source;
}
See also:
tizen_core_remove_source()
tizen_core_task_cb()

Emits the event to the tizen core.

The event is emitted to the event handler registered in the corresponding tizen_core.

Since :
9.0
Parameters:
[in]coreThe tizen core handle
[in]objectThe tizen core event object handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
static int emit_event(tizen_core_event_object_h object)
{
  tizen_core_h core = NULL;
  int ret;

  tizen_core_find("main", &core);
  ret = tizen_core_emit_event(core, object);
  if (ret != TIZEN_CORE_ERROR_NONE)
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to emit event");

  return ret;
}
See also:
tizen_core_add_event()
int tizen_core_find ( const char *  name,
tizen_core_h core 
)

Finds the tizen core from the name.

Since :
9.0
Remarks:
The core should not be released.
The core is available until tizen_core_task_h of the core is released.
Parameters:
[in]nameThe tizen core task name
[out]coreThe tizen core handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
TIZEN_CORE_ERROR_INVALID_CONTEXTInvalid context
#include <tizen_core.h>
{
  tizen_core_h core = NULL;
  int ret;

  ret = tizen_core_find("worker", &core);
  if (ret != TIZEN_CORE_ERROR_NONE)
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to find tizen core");
}

Finds the tizen core from this thread.

Since :
9.0
Remarks:
The core should not be released.
The core is available until tizen_core_task_h of the core is released.
Parameters:
[out]coreThe tizen core handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
TIZEN_CORE_ERROR_INVALID_CONTEXTInvalid context
#include <tizen_core.h>
{
  tizen_core_h core = NULL;
  int ret;

  ret = tizen_core_find_from_this_thread(&core);
  if (ret != TIZEN_CORE_ERROR_NONE)
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to find tizen core from this thread");
}
void tizen_core_init ( void  )

Initializes the tizen core.

Since :
9.0
See also:
tizen_core_shutdown()
tizen_core_ready()

Creates a tizen core poll fd handle.

Since :
9.0
Remarks:
The poll_fd should be released using tizen_core_poll_fd_destroy().
Parameters:
[out]poll_fdThe tizen core poll fd handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
TIZEN_CORE_ERROR_OUT_OF_MEMORYOut of memory
#include <tizen_core.h>
{
  tizen_core_poll_fd_h poll_fd = NULL;
  int ret;

  ret = tizen_core_poll_fd_create(&poll_fd);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create poll fd");
    return;
  }
}
See also:
tizen_core_poll_fd_destroy()

Destroys the tizen core poll fd (file descriptor) handle.

Since :
9.0
Remarks:
If the handle is already added to the source using the tizen_core_source_add_poll(), the handle will be removed from the source automatically after this function is called.
Parameters:
[in]poll_fdThe tizen core poll fd handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
{
  tizen_core_poll_fd_h poll_fd = NULL;
  int ret;

  ret = tizen_core_poll_fd_create(&poll_fd);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create poll fd");
    return;
  }

  ret = tizen_core_poll_fd_destroy(poll_fd);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to destroy poll fd");
  }
}
See also:
tizen_core_poll_fd_create()
int tizen_core_poll_fd_get_events ( tizen_core_poll_fd_h  poll_fd,
uint16_t *  events 
)

Gets the requested events from the poll fd handle.

Since :
9.0
Parameters:
[in]poll_fdThe tizen core poll fd handle
[out]eventsThe requested events
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
{
  tizen_core_poll_fd_h poll_fd = NULL;
  uint16_t events;
  int ret;

  ret = tizen_core_poll_fd_create(&poll_fd);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create poll fd");
    return;
  }

  tizen_core_poll_fd_set_fd(poll_fd, 0);
  tizen_core_poll_fd_set_events(poll_fd,
      TIZEN_CORE_POLL_EVENT_IN | TIZEN_CORE_POLL_EVENT_HUP);

  ret = tizen_core_poll_fd_get_events(poll_fd, &events);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get events from poll fd");
    tizen_core_poll_fd_destroy(poll_fd);
    return;
  }
}
See also:
tizen_core_poll_fd_set_events()
tizen_core_poll_event_e
int tizen_core_poll_fd_get_fd ( tizen_core_poll_fd_h  poll_fd,
int *  fd 
)

Gets the file descriptor from the poll fd handle.

Since :
9.0
Parameters:
[in]poll_fdThe tizen core poll fd handle
[out]fdThe file descriptor
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
{
  tizen_core_poll_fd_h poll_fd = NULL;
  int fd = -1;
  int ret;

  ret = tizen_core_poll_fd_create(&poll_fd);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create poll fd");
    return;
  }

  tizen_core_poll_fd_set_fd(poll_fd, 0);

  ret = tizen_core_poll_fd_get_fd(poll_fd, &fd);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get fd from poll fd");
    tizen_core_poll_fd_destroy(poll_fd);
    return;
  }
}
See also:
tizen_core_poll_fd_set_fd()
int tizen_core_poll_fd_get_returned_events ( tizen_core_poll_fd_h  poll_fd,
uint16_t *  returned_events 
)

Gets the returned events from the poll fd handle.

Since :
9.0
Parameters:
[in]poll_fdThe tizen core poll fd handle
[out]returned_eventsThe returned events
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
static bool source_prepare_cb(tizen_core_source_h source, int *timeout, void *user_data)
{
  *timeout = -1;
  return true;
}

static bool source_check_cb(tizen_core_source_h source, void *user_data)
{
  tizen_core_poll_fd_h poll_fd = (tizen_core_poll_fd_h)user_data;
  uint16_t returned_events = 0;

  tizen_core_poll_fd_get_returned_events(poll_fd, &returned_events);
  if (returned_events & TIZEN_CORE_POLL_EVENT_IN)
    return true;

  return false;
}

static bool source_dispatch_cb(tizen_core_source_h source, void *user_data)
{
  tizen_core_poll_fd_h poll_fd = (tizen_core_poll_fd_h)user_data;
  ssize_t bytes;
  int ret = 0;
  int fd;

  tizen_core_poll_fd_get_fd(poll_fd, &fd);
  bytes = read(fd, (void *)&ret, sizeof(ret));
  if (bytes < 0) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to read data. errno=%d", errno);
  } else if (bytes == 0) {
    dlog_print(DLOG_ERROR, LOG_TAG, "socket was closed. fd=%d", fd);
    tizen_core_source_destroy(source);
  } else {
    dlog_print(DLOG_INFO, LOG_TAG, "result=%d", ret);
  }

  return true;
}

static void source_finalize_cb(tizen_core_source_h source, void *user_data)
{
  tizen_core_poll_fd_h poll_fd = (tizen_core_poll_fd_h)user_data;

  tizen_core_poll_fd_destroy(poll_fd);
}

static tizen_core_source_h create_io_source(int fd, uint16_t events)
{
  tizen_core_source_h source = NULL;
  tizen_core_poll_fd_h poll_fd = NULL;
  tizen_core_h core = NULL;

  tizen_core_poll_fd_create(&poll_fd);
  tizen_core_poll_fd_set_fd(poll_fd, fd);
  tizen_core_poll_fd_set_events(poll_fd, events);

  tizen_core_source_create(&source);
  tizen_core_source_set_prepare_cb(source, source_prepare_cb, poll_fd);
  tizen_core_source_set_check_cb(source, source_check_cb, poll_fd);
  tizen_core_source_set_dispatch_cb(source, source_dispatch_cb, poll_fd);
  tizen_core_source_set_finalize_cb(source, source_finalize_cb, poll_fd);

  tizen_core_find("main", &core);
  tizen_core_add_source(core, source);

  return source;
}
See also:
tizen_core_poll_fd_set_events()
tizen_core_poll_event_e
int tizen_core_poll_fd_set_events ( tizen_core_poll_fd_h  poll_fd,
uint16_t  events 
)

Sets the requested events to the poll fd handle.

Since :
9.0
Parameters:
[in]poll_fdThe tizen core poll fd handle
[in]eventsThe requested events
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
{
  tizen_core_poll_fd_h poll_fd = NULL;
  int ret;

  ret = tizen_core_poll_fd_create(&poll_fd);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create poll fd");
    return;
  }

  tizen_core_poll_fd_set_fd(poll_fd, 0);

  ret = tizen_core_poll_fd_set_events(poll_fd,
      TIZEN_CORE_POLL_EVENT_IN | TIZEN_CORE_POLL_EVENT_OUT);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set events");
    tizen_core_poll_fd_destroy(poll_fd);
    return;
  }
}
See also:
tizen_core_poll_fd_get_events()
tizen_core_poll_event_e
int tizen_core_poll_fd_set_fd ( tizen_core_poll_fd_h  poll_fd,
int  fd 
)

Sets the file descriptor to the poll fd handle.

Since :
9.0
Parameters:
[in]poll_fdThe tizen core poll fd handle
[in]fdThe file descriptor
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
{
  tizen_core_poll_fd_h poll_fd = NULL;
  int ret;

  ret = tizen_core_poll_fd_create(&poll_fd);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create poll fd");
    return;
  }

  ret = tizen_core_poll_fd_set_fd(poll_fd, 0);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set fd to poll fd");
    tizen_core_poll_fd_destroy(poll_fd);
    return;
  }
}
See also:
tizen_core_poll_fd_get_fd()
int tizen_core_poll_fd_set_returned_events ( tizen_core_poll_fd_h  poll_fd,
uint16_t  returned_events 
)

Sets the returned events to the poll fd handle.

Since :
9.0
Parameters:
[in]poll_fdThe tizen core poll fd handle
[in]returned_eventsThe returned events
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
{
  tizen_core_poll_fd_h poll_fd = NULL;
  int ret;

  ret = tizen_core_poll_fd_create(&poll_fd);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create poll fd");
    return;
  }

  ret = tizen_core_poll_fd_set_returned_events(poll_fd,
      TIZEN_CORE_POLL_EVENT_IN | TIZEN_CORE_POLL_EVENT_OUT);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set returned events");
    tizen_core_poll_fd_destroy(poll_fd);
    return;
  }
}
See also:
tizen_core_poll_fd_get_events()
tizen_core_poll_event_e
bool tizen_core_ready ( void  )

Checks whether the tizen core is ready or not.

Since :
9.0
Returns:
true if the tizen core is ready, otherwise false.
See also:
tizen_core_init()
tizen_core_shutdown()

Removes the source from the tizen core.

Since :
9.0
Remarks:
If the source is not added to the tizen core, this function returns TIZEN_CORE_ERROR_INVALID_CONTEXT.
Parameters:
[in]coreThe tizen core handle
[in]sourceThe tizen core source handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
TIZEN_CORE_ERROR_INVALID_CONTEXTInvalid context
#include <tizen_core.h>
static void remove_source(tizen_core_source_h source)
{
  tizen_core_h core = NULL;
  int ret;

  tizen_core_find("main", &core);
  ret = tizen_core_remove_source(core, source);
  if (ret != TIZEN_CORE_ERROR_NONE)
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to remove source");
  else
    dlog_print(DLOG_INFO, LOG_TAG, "source is removed");
}
See also:
tizen_core_add_source()
void tizen_core_shutdown ( void  )

Shutdowns the tizen core.

Since :
9.0
See also:
tizen_core_init()
tizen_core_ready()

Waits for some events on the file descriptor.

The tizen core source must be created using the tizen_core_source_create().

Since :
9.0
Parameters:
[in]sourceThe tizen core source handle
[in]poll_fdThe poll fd handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
TIZEN_CORE_ERROR_INVALID_CONTEXTInvalid context
#include <tizen_core.h>
static tizen_core_poll_fd_h add_poll_fd_to_source(tizen_core_source_h source, int fd)
{
  tizen_core_poll_fd_h poll_fd = NULL;
  int ret;

  tizen_core_poll_fd_create(&poll_fd);
  tizen_core_poll_fd_set_fd(poll_fd, fd);
  tizen_core_poll_fd_set_events(poll_fd, TIZEN_CORE_POLL_EVENT_IN);
  ret = tizen_core_source_add_poll(source, poll_fd);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add poll fd");
    tizen_core_poll_fd_destroy(poll_fd);
    return NULL;
  }

  return poll_fd;
}
See also:
tizen_core_source_create()
tizen_core_source_set_prepare_cb()
tizen_core_source_set_check_cb()
tizen_core_source_set_dispatch_cb()
tizen_core_source_set_finalize_cb()
tizen_core_source_remove_poll()

Creates a tizen core source handle.

Since :
9.0
Remarks:
The source should be released using tizen_core_source_destroy().
Parameters:
[out]sourceThe tizen core source handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
TIZEN_CORE_ERROR_OUT_OF_MEMORYOut of memory
TIZEN_CORE_ERROR_INVALID_CONTEXTInvalid context
#include <tizen_core.h>
{
  tizen_core_source_h source = NULL;
  int ret;

  ret = tizen_core_source_create(&source);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create source");
    return ret;
  }
}
See also:
tizen_core_add_source()
tizen_core_remove_source()
tizen_core_source_destroy()

Destroys the tizen core source handle.

Since :
9.0
Parameters:
[in]sourceThe tizen core source handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
{
  tizen_core_source_h source = NULL;
  int ret;

  ret = tizen_core_source_create(&source);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create source");
    return ret;
  }

  ret = tizen_core_source_destroy(source);
  if (ret != TIZEN_CORE_ERROR_NONE)
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to destroy source");
}
See also:
tizen_core_source_create()
tizen_core_remove_source()

Removes to wait for some events on the file descriptor.

Since :
9.0
Parameters:
[in]sourceThe tizen core source handle
[in]poll_fdThe poll fd handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
TIZEN_CORE_ERROR_INVALID_CONTEXTInvalid context
#include <tizen_core.h>
static void remove_poll_from_source(tizen_core_source_h source, tizen_core_poll_fd_h poll_fd)
{
  int ret;

  ret = tizen_core_source_remove_poll(source, poll_fd);
  if (ret != TIZEN_CORE_ERROR_NONE)
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to remove poll fd");
  else
    dlog_print(DLOG_INFO, LOG_TAG, "Poll fd is removed");
}
See also:
tizen_core_source_create()
tizen_core_source_add_poll()
int tizen_core_source_set_check_cb ( tizen_core_source_h  source,
tizen_core_source_check_cb  callback,
void *  user_data 
)

Sets the check callback function to the tizen core source.

This function is not mandatory. If the callback function is not set, the tizen core source is processed.

Since :
9.0
Parameters:
[in]sourceThe tizen core source handle
[in]callbackThe callback function to be invoked when the source is ready to be processed
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
static bool source_prepare_cb(tizen_core_source_h source, int *timeout, void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "prepare callback is invoked");
  return true;
}

static bool source_check_cb(tizen_core_source_h source, void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "check callback is invoked");
  return true;
}

static bool source_dispatch_cb(tizen_core_source_h source, void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "dispatch callback is invoked");
  return true;
}

static tizen_core_source_h create_source(void)
{
  tizen_core_source_h source = NULL;
  int ret;

  ret = tizen_core_source_create(&source);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create source");
    return NULL;
  }

  tizen_core_source_set_prepare_cb(source, source_prepare_cb, NULL);
  tizen_core_source_set_dispatch_cb(source, source_dispatch_cb, NULL);

  ret = tizen_core_source_set_check_cb(source, source_check_cb, NULL);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set check callback");
    tizen_core_source_destroy(source);
    return NULL;
  }

  return source;
}
See also:
tizen_core_source_create()
tizen_core_source_check_cb()
int tizen_core_source_set_dispatch_cb ( tizen_core_source_h  source,
tizen_core_source_dispatch_cb  callback,
void *  user_data 
)

Sets the dispatch callback function to the tizen core source.

This function is mandatory. Before adding the source handle to the tizen_core_h using tizen_core_add_source(), the callback function should be set.

Since :
9.0
Parameters:
[in]sourceThe tizen core source handle
[in]callbackThe callback function to be dispatched events
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
static bool source_prepare_cb(tizen_core_source_h source, int *timeout, void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "prepare callback is invoked");
  return true;
}

static bool source_check_cb(tizen_core_source_h source, void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "check callback is invoked");
  return true;
}

static bool source_dispatch_cb(tizen_core_source_h source, void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "dispatch callback is invoked");
  return true;
}

static tizen_core_source_h create_source(void)
{
  tizen_core_source_h source = NULL;
  int ret;

  ret = tizen_core_source_create(&source);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create source");
    return NULL;
  }

  tizen_core_source_set_prepare_cb(source, source_prepare_cb, NULL);
  tizen_core_source_set_check_cb(source, source_check_cb, NULL);

  ret = tizen_core_source_set_dispatch_cb(source, source_dispatch_cb, NULL);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set dispatch callback");
    tizen_core_source_destroy(source);
    return NULL;
  }

  return source;
}
See also:
tizen_core_source_create()
tizen_core_source_dispatch_cb()
int tizen_core_source_set_finalize_cb ( tizen_core_source_h  source,
tizen_core_source_finalize_cb  callback,
void *  user_data 
)

Sets the finalize callback function to the tizen core source.

This function is not mandatory. If there is anything you need to do when the source is removed, use this function to set the callback function.

Since :
9.0
Parameters:
[in]sourceThe tizen core source handle
[in]callbackThe callback function to finalize the source
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
static bool source_prepare_cb(tizen_core_source_h source, int *timeout, void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "prepare callback is invoked");
  return true;
}

static bool source_check_cb(tizen_core_source_h source, void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "check callback is invoked");
  return true;
}

static bool source_dispatch_cb(tizen_core_source_h source, void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "dispatch callback is invoked");
  return true;
}

static void source_finalize_cb(tizen_core_source_h source, void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "finalize callback is invoked");
}

static tizen_core_source_h create_source(void)
{
  tizen_core_source_h source = NULL;
  int ret;

  ret = tizen_core_source_create(&source);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create source");
    return NULL;
  }

  tizen_core_source_set_prepare_cb(source, source_prepare_cb, NULL);
  tizen_core_source_set_check_cb(source, source_check_cb, NULL);
  tizen_core_source_set_dispatch_cb(source, source_dispatch_cb, NULL);

  ret = tizen_core_source_set_finalize_cb(source, source_finalize_cb, NULL);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set finalize callback");
    tizen_core_source_destroy(source);
    return NULL;
  }

  return source;
}
See also:
tizen_core_source_create()
tizen_core_source_finalize_cb()
tizen_core_remove_source()
tizen_core_source_destroy()
int tizen_core_source_set_prepare_cb ( tizen_core_source_h  source,
tizen_core_source_prepare_cb  callback,
void *  user_data 
)

Sets the prepare callback function to the tizen core source.

This function is not mandatory. If you want to set a timeout value to ensure that the poll(), the callback function should be set.

Since :
9.0
Parameters:
[in]sourceThe tizen core source handle
[in]callbackThe callback function to be invoked when the source is ready to be processed
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
static bool source_prepare_cb(tizen_core_source_h source, int *timeout, void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "prepare callback is invoked");
  return true;
}

static bool source_check_cb(tizen_core_source_h source, void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "check callback is invoked");
  return true;
}

static bool source_dispatch_cb(tizen_core_source_h source, void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "dispatch callback is invoked");
  return true;
}

static tizen_core_source_h create_source(void)
{
  tizen_core_source_h source = NULL;
  int ret;

  ret = tizen_core_source_create(&source);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create source");
    return NULL;
  }

  ret = tizen_core_source_set_prepare_cb(source, source_prepare_cb, NULL);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set prepare callback");
    tizen_core_source_destroy(source);
    return NULL;
  }

  tizen_core_source_set_check_cb(source, source_check_cb, NULL);
  tizen_core_source_set_dispatch_cb(source, source_dispatch_cb, NULL);

  return source;
}
See also:
tizen_core_source_create()
tizen_core_source_prepare_cb()
tizen_core_source_add_poll()

Sets the priority to the tizen core source.

Since :
9.0
Parameters:
[in]sourceThe tizen core source handle
[in]priorityThe priority value
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
static bool idle_job_cb(void *user_data)
{
  dlog_print(DLOG_INFO, LOG_TAG, "idler is invoked");
  return true;
}

static tizen_core_source_h create_idle_source(void)
{
  tizen_core_source_h source = NULL;
  tizen_core_h core = NULL;
  int ret;

  tizen_core_find("main", &core);
  ret = tizen_core_add_idle_job(core, idle_job_cb, NULL, &source);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add idle job");
    return NULL;
  }

  ret = tizen_core_source_set_priority(source, TIZEN_CORE_PRIORITY_HIGH);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set priority");
    tizen_core_source_destroy(source);
    return NULL;
  }

  return source;
}
See also:
tizen_core_priority_e
int tizen_core_task_create ( const char *  name,
bool  use_thread,
tizen_core_task_h task 
)

Creates the tizen core task handle.

If the name is "main", the use_thread should be set to 'false'. Otherwise, it returns TIZEN_CORE_ERROR_INVALID_PARAMETER.

Since :
9.0
Remarks:
The task should be released using tizen_core_task_destroy().
Parameters:
[in]nameThe name of the task
[in]use_threadtrue, if the task should be run in a separate thread, otherwise false
[out]taskThe tizen core task handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
TIZEN_CORE_ERROR_OUT_OF_MEMORYOut of memory
TIZEN_CORE_ERROR_INVALID_CONTEXTInvalid context
#include <tizen_core.h>
{
  tizen_core_task_h task = NULL;
  int ret;

  tizen_core_init();
  ret = tizen_core_task_create("main", false, &task);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    tizen_core_shutdown();
    return -1;
  }
}
See also:
tizen_core_task_destroy()

Destroys the tizen core task handle.

Since :
9.0
Parameters:
[in]taskThe tizen core task handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
{
  tizen_core_task_h task = NULL;
  int ret;

  tizen_core_init();
  ret = tizen_core_task_create("main", false, &task);
  if (ret != TIZEN_CORE_ERROR_NONE)
    return ret;

  ret = tizen_core_task_destroy(task);
  if (ret != TIZEN_CORE_ERROR_NONE)
    return ret;
}
See also:
tizen_core_task_create()

Gets the tizen core from the tizen core task handle.

Since :
9.0
Remarks:
The core should not be released.
The core is available until the task is released.
Parameters:
[in]taskThe tizen core task handle
[out]coreThe tizen core handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
{
  tizen_core_task_h task = NULL;
  tizen_core_h core = NULL;
  int ret;

  tizen_core_init();
  tizen_core_task_create("worker", true, &task);
  ret = tizen_core_task_get_tizen_core(task, &core);
  if (ret != TIZEN_CORE_ERROR_NONE)
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get tizen core");
}
int tizen_core_task_is_running ( tizen_core_task_h  task,
bool *  running 
)

Checks whether the tizen core task is running or not.

Since :
9.0
Parameters:
[in]taskThe tizen core task handle
[out]runningtrue if the core task is running,
otherwise false if not running
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
{
  tizen_core_task_h task = NULL;
  bool running = false;
  int ret;

  tizen_core_init();
  ret = tizen_core_task_create("worker", true, &task);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    tizen_core_shutdown();
    return ret;
  }

  ret = tizen_core_task_run(task);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to run task");
    tizen_core_task_destroy(task);
    tizen_core_shutdown();
    return ret;
  }

  ret = tizen_core_task_is_running(task, &running);
  if (ret != TIZEN_CORE_ERROR_NONE)
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to check whether the task is running or not");
  else
    dlog_print(DLOG_INFO, LOG_TAG, "worker task is %s", running ? "running" : "not running");
}
See also:
tizen_core_task_run()
tizen_core_task_quit()

Exits the main loop of the tizen core task.

Since :
9.0
Parameters:
[in]taskThe tizen core task handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
#include <tizen_core.h>
{
  tizen_core_task_h task = NULL;
  int ret;

  tizen_core_init();
  tizen_core_task_create("worker", true, &task);
  tizen_core_task_run(task);
  ret = tizen_core_task_quit(task);
  if (ret != TIZEN_CORE_ERROR_NONE)
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to exit the main loop");
}
See also:
tizen_core_task_run()

Runs the main loop of the tizen core task.

Since :
9.0
Parameters:
[in]taskThe tizen core task handle
Returns:
0 on success, otherwise a negative error value
Return values:
TIZEN_CORE_ERROR_NONESuccessful
TIZEN_CORE_ERROR_INVALID_PARAMETERInvalid parameter
TIZEN_CORE_ERROR_INVALID_CONTEXTInvalid context
#include <tizen_core.h>
{
  tizen_core_task_h task = NULL;
  int ret;

  tizen_core_init();
  ret = tizen_core_task_create("worker", true, &task);
  if (ret != TIZEN_CORE_ERROR_NONE) {
    tizen_core_shutdown();
    return ret;
  }

  ret = tizen_core_task_run(task);
  if (ret != TIZEN_CORE_ERROR_NONE)
    dlog_print(DLOG_ERROR, LOG_TAG, "Failed to run task");
}
See also:
tizen_core_task_quit()