Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here

atomdict

A data structure for data exchange between multi lua states.

Subscribe to updates I use atomdict


Statistics on atomdict

Number of watchers on Github 37
Number of open issues 0
Main language C
Average time to merge a PR 2 days
Open pull requests 0+
Closed pull requests 0+
Last commit over 7 years ago
Repo Created about 8 years ago
Repo Last Updated over 2 years ago
Size 130 KB
Organization / Authorcloudwu
Contributors2
Page Updated
Do you use atomdict? Leave a review!
View atomdict activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating atomdict for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Atom Dict

Atomdict implements a data structure for multi lua state.

You can use it in multi-threads , create one lua state per thread. Atomdict will help you exchange a group data atomic between lua states.

Quick Example

In data server :

  local ad = require "atomdict"
  local handle = ad.new_handle { HP = 100 , Name = "Alice" }

  -- Send handle (A integer) to other lua state in other thread

In data client :

  local ad = require "atomdict"

  -- ...

  local obj = ad.new(handle) -- get data handle from other lua state before.

  -- You can use pairs in this object
  for k,v in pairs(obj) do
    print(k,v)
  end

  -- Set obj.Name in local state, others can't see it before call ad.barrier()
  obj.Name = "Bob"

  -- put barrier in your main loop of the program
  ad.barrier()

API

atomdict.new_handle( { key = value(number or string) , ... } , [typename] )

Use a table to init atomdict . You can name the type. If you have many objects with the same structure , giving a typename will improve the performance.

It returns an integer handle.

atomdict.delete_handle( handle )

Delete an atomdict handle. You must delete it before none of the object binding to the handle.

atomdict.new(handle)

Create an object binding the atomdict handle. It returns an userdata like a table.

atomdict.barrier()

Call barrier to commit atomdict objects that their changes could be seen by others.

atomdict.dump(object)

Print the object to the stdout. (for debug)

atomdict.dump_handle(handle)

Print the handle to the stdout. (for debug)

Question ?

  • Send me an email : http://www.codingnow.com/2000/gmail.gif
  • My Blog : http://blog.codingnow.com
  • Design : http://blog.codingnow.com/2012/07/dev_note_23.html (in Chinese)
atomdict list of languages used
Other projects in C