Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

sassembla/Chanquo

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chanquo

Chanquo(pronounce chanko) is the partial implementation of Golang-channel for Unity.

usage

create channel then send data to channel

assume that the type like below is exists,

public struct T {}

create typed channel and send T data to the channel.

var ch = Chan<T>.Make();
ch.Send(new T(){});

receive data from channel

// start receiving data asynchronously.
ch.Receive(
    (T data, bool ok) => {
        // ok will become false when the channel is closed somewhere.
        // when ok is false, data is empty.
    }
);

or 

// receive data until Chan<T> is closed.
yield return Channels.For<T>(
    T t =>
    {
        
    }
);

or 

// wait first data then go through.
yield return Channels.WaitFirst<T>();

or 

// wait first data then go through and get received data.
var cor = Channels.WaitFirstResult<T>();
yield return cor;
var result = cor.Result;

close channel

Close() closes channel. or you can close channel by specify type.

ch.Close();

or

Channels.Close<T>();

when the Chan is closed, WaitFirst(), WaitFirstResult() and For's blocking will end.

license

license

About

golang-channel partial implementation for Unity.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.