core/tools
(msys toolchains) and uses xmake to compile core sources on windowsxmake/packages
for templates-def:xxx.def
flags failed for msvctbox add a coroutine library with stackfull mode and provide the following features.
1. yield
2. suspend and resume
3. sleep
4. io scheduler with (epoll, poll, kqueue, select, poll ..)
5. supports stream, http and other all io modules of tbox
6. channel
7. lock
8. semaphore
Benchbox is a benchmark testing utilities based on xmake and tbox.
Please install xmake first: xmake
$ xmake
$ xmake coroutine -n switch
tbox: 10000000 switches in 205 ms, 48780487 switches per second
boost: 10000000 switches in 728 ms, 13736263 switches per second
libmill: 10000000 switches in 525 ms, 19047619 switches per second
libtask: 10000000 switches in 1602 ms, 6242197 switches per second
golang: 10000000 switches in 1558 ms, 6418485 switches per second
tbox supports sqlite3 and mysql databases now(depends on libsqlite3.a and libmysql.a) and provides the unified api to access database.
We only need pass a given url for connecting and accessing it.
A simple example:
/* init a mysql database
*
* mysql database url:
*
* - "sql://localhost:3306/?type=mysql&username=xxxx&password=xxxx&database=xxxx"
*
* sqlite3 database url:
*
* - "sql:///home/file.sqlitedb?type=sqlite3"
* - "/home/file.sqlite3"
* - "file:///home/file.sqlitedb"
* - "C://home/file.sqlite3"
*/
tb_database_sql_ref_t database = tb_database_sql_init("sql://localhost/?type=mysql&username=xxxx&password=xxxx&database=test");
if (database)
{
// open database
if (tb_database_sql_open(database))
{
// execute sql statement
if (tb_database_sql_done(database, "select * from test"))
{
// load all results only for the select statement
tb_iterator_ref_t result = tb_database_sql_result_load(database, tb_true);
if (result)
{
// trace
tb_trace_i("row: size: %lu", tb_iterator_size(result));
// walk all rows
tb_for_all_if (tb_iterator_ref_t, row, result, row)
{
// trace
tb_trace_i("[row: %lu, col: size: %lu]: ", row_itor, tb_iterator_size(row));
// walk all values
tb_for_all_if (tb_database_sql_value_t*, value, row, value)
{
// trace
tb_tracet_i("[%s:%s] ", tb_database_sql_value_name(value), tb_database_sql_value_text(value));
}
}
tb_database_sql_result_exit(database, result);
}
}
else tb_trace_e("done %s failed, error: %s", sql, tb_state_cstr(tb_database_sql_state(database)));
}
else tb_trace_e("open failed: %s", tb_state_cstr(tb_database_sql_state(database)));
// exit database
tb_database_sql_exit(database);
}